Discussion :: C-MCQs
-
Comment on the output of this C code?
int main()
{
char c;
int i = 0;
FILE *file;
file = fopen("test.txt", "w+");
fprintf(file, "%c", 'a');
fprintf(file, "%c", -1);
fprintf(file, "%c", 'b');
fclose(file);
file = fopen("test.txt", "r");
while ((c = fgetc(file)) != -1)
printf("%c", c);
return 0;
. }
Answer : Option A
Explanation :
None.
Output:
$ cc pgm3.c
$ a.out
a
Be The First To Comment