I am currently having a course on C and working on an exercise that requires my program to handle files. As an example, just for my own understanding without trying to do anything more complex for now, I tried to run the following program:
#include <stdio.h>
#include <stdlib.h>
int main(){
FILE *datei = fopen("employees.txt", "w");
fprintf(datei, "Annan");
fclose(datei);
return 0;
}
This should normally, if I understood correctly, generate the .txt file within the same folder of my C file, in case the file does not exist within the folder or overwrite it, if it does: However, no matter how many time I run the program no file is being generated nor overwritten in case it exists.
I then thought that my *.c file being saved within the cloud was the problem, so I saved it directly on my PC – same conclusion
I proceeded to inserting the definite path:
FILE *datei = fopen("C:\Users\für\JustCoding", "w");
fprintf(datei, "Annan");
same outcome…
I restarted my PC (Windows 11 Home) and repeated above-mentioned steps… Nothing…
Now I am pretty sure this has nothing to do with compilation errors, since my terminal does show me that the program was executed (well, I might be wrong but I’m open for correction), so I am currently at a stand-still
Did any of you face a similar issue? If yes, how did you solve it? Anyone that can help is welcome the do so…
Thank you
AJcodes is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.