Hi.
I use CCs 3.3 and c6713 simulator. I want read file with binary data from file. I wrote this program:
#include <stdio.h>
#define BUFSIZE 80
void main()
{
char fileStr[BUFSIZE];
size_t readSize=0;
FILE *fptr=NULL;
fprintf (stderr, "reading from file\n");
if (NULL == (fptr = fopen("file.bin", "r")))
{
fprintf(stderr, "can't open file");
return 0;
}
while (! feof(fptr))
{
readSize = fread(fileStr, sizeof(char), BUFSIZE, fptr);
fprintf(stderr, "Read a %d byte \n", readSize);
}
fprintf(stderr, "file is over\n");
fclose(fptr);
}
program output:
reading from file
Read a 472 byte
file is over
But the program reads only part of file, only 472 bytes. I tried to change the BUFSIZE, but it does not help, the program reads only 472 bytes, then the feof reports that file ended.
Does this restriction only for debugging on simulator?