Here is the code
if((fp1 = fopen(fname,"rb")) == NULL) {
printf("error opening file %s \n",fname);
exit(1);
}
while(1) {
if(fread(fieldlen,(2 * sizeof(fieldlen[0])),1,fp1)<1){
if(feof(fp1)) break;
}
bytes_read += (2 * sizeof(int));
memset((char*)string,0,sizeof(string));
if(fread(string,(fieldlen[0]+fieldlen[1]),1,fp1)<1) {;
fflush(stdout);
if(feof(fp1)) break;
printf("ERROR \n");
}
printf("String is : %s,%d,%d \n",string,fieldlen[0],fieldlen[1]);
strncpy(string1, string+fieldlen[0],fieldlen[1]);
bytes_read += (fieldlen[0]+fieldlen[1]);
printf("String is : %s \n",string1);
}
fclose(fp1);
****************************
Input File:
^H^@^@^@,^@^@^@notused^@O3,8113141004,IV,124,50,1107801594,100,1,1
^@^H^@^@^@X^@^@^@notused^@E3,124,50,8113141004,1107801594,1107801595,2,63000023,1107801594,124,50,^B1,2,EventText^C
^@^H^@^@^@,^@^@^@notused^@O3,8113141004,IV,124,50,1107801594,200,2,2
^@^H^@^@^@o^@^@^@notused^@E3,124,50,8113141004,1107801594,1107801595,1,63000023,1107801594,124,50,^B1,2,This is the data; ANI=4027160503^C
^@^H^@^@^@X^@^@^@notused^@E3,124,50,8113141004,1107801594,1107801595,2,63000023,1107801594,124,50,^B1,2,EventText^C
^@^H^@^@^@
After it encounters the E3 records it bails out.
Does it have something to do that how the binary file is getting created.