The source code of program_1 is as follows.
/* program_1.c */
#include <stdio.h>
int main(void)
{
FILE *ofp;
ofp = fopen("myfile", "w");
fprintf(ofp, "test");
getchar();
fclose(ofp);
getchar();
return 0;
}
The terminal running one program_1 and another terminal for viewing the contents of myfile are first displayed.
If I check the contents of myfile while running program_1, string "test" is not printed.
However, if I input the enter key once while running program_1 and check the contents of myfile, I can see that the "test" string has been printed.
question : Why is this happening?