A
acp26b
I need to read a binary to put into a struct. For some reason the code
will not work. In this section of code i am just looping through the
file to get the number of records so i can then build the correct size
array. Nothing was happening so i used the variable test and found out
that read is returning -1. Any ideas?
char *inFileName = NULL;
void *input;
int fdi;
int sizeOfData = sizeof(bin_record);
fdi = open(inFileName, O_RDONLY);
if (fdi == -1){
printf("ERROR: UNABLE TO OPEN DATA FILE\n");
exit (-1);
}
test = read(fdi, input, sizeOfData);
//while( read(fdi, ptr, sizeOfData) > 0){
// recordCount++;
//}
printf("%d \n", test);
close (inFileName);
will not work. In this section of code i am just looping through the
file to get the number of records so i can then build the correct size
array. Nothing was happening so i used the variable test and found out
that read is returning -1. Any ideas?
char *inFileName = NULL;
void *input;
int fdi;
int sizeOfData = sizeof(bin_record);
fdi = open(inFileName, O_RDONLY);
if (fdi == -1){
printf("ERROR: UNABLE TO OPEN DATA FILE\n");
exit (-1);
}
test = read(fdi, input, sizeOfData);
//while( read(fdi, ptr, sizeOfData) > 0){
// recordCount++;
//}
printf("%d \n", test);
close (inFileName);