+ 2
Is it possible to name a file using a variable in c programming?
The user should be able to name the file that would be created.
6 Answers
+ 7
Yup. It is possible.
See this turorial
https://www.sololearn.com/learn/C/2952/
+ 5
// Yes you can , fopen() will create new file if that file.txt is dose not exist
FILE *fp;
fp=fopen("file.txt","w");
+ 3
I made this code using a variable.
See this code.
https://code.sololearn.com/cRLY3Pi661TF/?ref=app
+ 2
LastSecond959
If try open the file without name it does not work.
+ 1
Yes the filename can be a variable whose value is provided by the user.
0
Pedro H.J So the input must be name.txt right? Is it valid if I just input the name of the file without .txt or .in etc?