fopen not working properly?
Still learning c programming. I compiled the following code:
Code:
#include <stdio.h>
main() {
FILE *file;
if ((file = fopen("test.txt", "r") ) == NULL) {
printf("File could not be opened.\n");
}
else {
printf("File opened successfully.\n");
}
return 0;
}
When I run the program in cmd I get one line "File opened successfully" but do not see any of the contents of the file test.txt, located in the same directory as the program. Obviously the file test.txt was found, but why aren't its contents printed out in cmd? The file test.txt contains the text "This is your requested file.". Is it a problem with windows 7 maybe?