I got it fixed. Thanks for all the help.
I\'ve now looked through quite a few articles, forum posts and topics here; however, none have actually fixed my issue. The
The file is created, but not where you expect it to be.
Check the working directory (getcwd
).
Try perror
. It's possible you don't have permissions or something like that.
FILE *receipt = fopen("receipt.txt", "w");
if (!receipt)
perror("fopen");
The only explanations that makes sense are that you don't have permissions to create the file in the working directory, or the working directory is not where you are looking for the file to be created.
fopen()
not working
Well, of course it works. You shouldn't get in the mindset that the standard library doesn't work.
No warnings/notices or otherwise stuff to give me any idea of what is wrong.
You did not check for errors after calling fopen()
. If you don't check for errors, how do you expect them to be delivered to you?
You should use strerror
to format the error yourself or perror
to print the system error matching with the errno.
man errno
may help you