Check with these questions that you understand how to use files in C.
There is something wrong with this piece of code. What it is?:
1 FILE *fptr; 2 char b = ‘b’; 3 char *c = &b; 4 if (fptr = fopen(“file.txt”, “r”))!= NULL) 5 { 6 while(!feof(fptr)) 7 { 8 fwrite(c, sizeof(char),1,fptr) 9 printf(“Character: %c”,*c); 10 } 11 fclose(fptr); 12 }
You open the file fptr
, whose size is 100 bytes.
Which of these pairs of sentences is equivalent?
You open the file fptr
. You start reading byte by byte,
till the end of file. At that point, which of these sentences is correct?: