#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
Go to the source code of this file.
Functions | |
int | main (int argc, char *argv[]) |
int main | ( | int | argc, | |
char * | argv[] | |||
) |
Definition at line 26 of file readFileRoot.c.
00027 { 00028 int file; 00029 int num, i, j; 00030 int lidos; 00031 char header[ 64 ]; 00032 00033 for( j = 1; j < argc; j++ ) 00034 { 00035 i = 0; 00036 file = open( argv[ j ], O_RDONLY ); 00037 if( file > 0 ) 00038 { 00039 lidos = read( file, (char *)&header, 64 ); 00040 if( lidos != 64 ) 00041 { 00042 fprintf( stdout, "main erro ao ler o valor de header: lidos %u", 00043 lidos); 00044 fprintf( stdout, " bytes de um total de 64 bytes.\n" ); 00045 } 00046 else if( lidos == -1 ) 00047 { 00048 fprintf( stdout, "main erro %u (%s) ao ler o valor de header\n", 00049 errno, strerror( errno ) ); 00050 } 00051 while( read( file, (char *)&num, 4 ) == 4 ) 00052 { 00053 fprintf( stderr, "%4d ", num ); 00054 if( ++i % 2 == 0 ) 00055 fprintf( stderr, "\n" ); 00056 } 00057 close( file ); 00058 } 00059 else 00060 fprintf( stderr, "Nao consegui abrir o arquivo\n" ); 00061 } 00062 00063 return( 0 ); 00064 }