Vidyalelo
C++ Programming · Q360

C++ miscellaneous

Programming · C++ Programming · question 360

Q360

What will be the output of the following C++ code? #include int main () int n; FILE * p; char buffer [5]; p = fopen ("myfile.txt", "w+"); for ( n = 'A' ; n <= 'D' ; n++) fputc ( n, p); rewind (p); fread (buffer, 1, 5, p); fclose (p); buffer[3] = '\0'; puts (buffer); return 0;

A.
ABCD
B.
ABC
Answer
C.
ABCDE
D.
ADCA

Answer: Option B

Solution

Answer: Option B
No explanation is given for this question Let's Discuss on Board