?
What will be the output of the following C++ code in text files?
What will be the output of the following C++ code in text files?
#include <stdio.h>
int main ()
{
char buffer[BUFSIZ];
FILE *p1, *p2;
p1 = fopen ("myfile.txt", "w");
p2 = fopen ("myfile2.txt", "a");
setbuf ( p1 , buffer );
fputs ("Buffered stream", p1);
fflush (p1);
setbuf ( p2 , NULL );
fputs ("Unbuffered stream", p2);
fclose (p1);
fclose (p2);
return 0;
}
#include <stdio.h>
int main ()
{
char buffer[BUFSIZ];
FILE *p1, *p2;
p1 = fopen ("myfile.txt", "w");
p2 = fopen ("myfile2.txt", "a");
setbuf ( p1 , buffer );
fputs ("Buffered stream", p1);
fflush (p1);
setbuf ( p2 , NULL );
fputs ("Unbuffered stream", p2);
fclose (p1);
fclose (p2);
return 0;
}
Join the Discussion
Login to post a comment or share your explanation.
Login