-
Getchar() problems
PHP Code:
FILE *pFile = fopen("pw.txt", "a");
if (pFile != NULL)
{
for (int i = 1; i <= stop; i++)
{
//fprintf stuff
}
fclose(pFile);
printf("Successfully written to file");
}
else
printf("Could not open output file");
getchar();
I want to have the getchar() so the user has time to read what is being printed to the screen. The problem is, it only works if fopen() fails. If the file opens then it is as if getchar() isn't there. What's causing this?
-
Try a code block:
PHP Code:
FILE *pFile = fopen("pw.txt", "a");
if (pFile != NULL)
{
for (int i = 1; i <= stop; i++)
{
//fprintf stuff
}
fclose(pFile);
printf("Successfully written to file");
}
else {
printf("Could not open output file");
}
getchar();