The output is count = 255
We did write 256 characters, Why do we only get 255 of them?
#include <stdio.h>
int main(void)
{
FILE *fp;
char c;
int count;
int i;
fp = fopen("file", "wb");
for (i = 0; i < 256; i++)
fputc(i, fp);
fclose(fp);
fp = fopen("file", "rb");
count = 0;
while ((c = fgetc(fp)) != EOF)
count++;
printf("count = %d\n", count);
return 0;
}
沒有留言:
張貼留言