English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

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.

2007-01-30 03:35:22 · 5 answers · asked by Anonymous in Computers & Internet Programming & Design

5 answers

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

2007-01-30 08:58:53 · answer #1 · answered by COD 3 · 0 0

.

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> sum > output1.txt

The above eg would print the ouput of the program "sum" in to the file ouput1.txt.

**********
Vasu M
**********

2007-01-30 20:43:40 · answer #2 · answered by V@su Maniram 3 · 0 0

Assuming you have some variety of loop putting out each and each string (a single notice?) one after the different, additionally placed out a clean after all and sundry. in case you want to get greater beneficial fancy, you're able to additionally try for the final string and not placed out a string for it. wish that helps.

2016-11-01 21:30:27 · answer #3 · answered by Anonymous · 0 0

Alt + f5

2007-01-30 04:21:53 · answer #4 · answered by Sumanth 3 · 0 0

sophisticated point. lookup over the search engines. that will may help!

2014-11-04 14:19:55 · answer #5 · answered by Anonymous · 0 0

fedest.com, questions and answers