This is the first time I'm coding C in Windows and a weird bug is driving me crazy.
I'm trying to open a .txt file using fopen, and it keeps giving me the "file doesn't exist" error (it also gave me the "no permission" error, once).
My code is as follows (doesn't get any simpler than that):
FILE *file;
if((file=fopen("C:\\Users\\ste\\Desktop\\file.txt", "r"))==NULL)
{
printf("Cannot open file.\n");
puts(strerror(errno));
getchar();
exit(1);
}
Am I missing something here? Thanks in advance!
I bet you have the Windows "hide extensions" bugfeature turned on. So the file which is really called "file.txt" appears in your Explorer as "file". And if it appeared to be "file.txt" in the Explorer, it would have to be named "file.txt.txt" on the hard drive.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With