I need to display the whole output produced on the userscreen to be displayed in a file using C program. Any one who knows please help me.
How to display the output in a file using C program?
Use fprintf( )
fprintf( this space for pointer to a file,"Whatever you want to output in file")
example:
out = fopen("final.txt","w"); // out is pointer to file
fopen opens file final.txt
w means to write to file
fprintf(out, "Welcome to Hollywood\n");
when you build and run program, and open the file, it should have Welcome to Hollywood in it.
****Make sure you save the file in the projects folder of the program
Reply:Alt + f5
Reply:.
You can use fprintf() to directly send the output to files.
Otherwise you can write ordinary C program and then when executing it in the prompt, give a file name with a greater than symbol.
eg.
c:/TurboC/bin%26gt; sum %26gt; output1.txt
The above eg would print the ouput of the program "sum" in to the file ouput1.txt.
**********
Vasu M
**********
snapdragon2
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment