C prog..except input ,write to textfile??
Hi. Really new to Linux and a wee bit familiar with C. I want to write a small code that will ask user his/her name when run and then write it to a text file called name.txt . that's it.
i know the C code part but I dont know how I would write to a text file on the disk. I mean I know the printf, scanf parts, etc
scanf() will handle the input. To write to a file on disk, you must open a file and use fprintf()
char *nm = "Malicious";
/* open a file in the current working
directory named "names.txt" */
nf = fopen("names.txt", "w");
/* write a name to it */
fprintf(nf, "%s\n", nm);
/* close it */
Let me know when you need some more homework done. :-)
|All times are GMT -5. The time now is 08:12 AM.|