Hi. Can someone help me with how to transfer/print your last output in a word file? I'm researching and can't find a way on C. My code in C so don't suggest solutions for C++ thank you :).

If by "word file" you mean a text file, just use fopen() with the name of the file (surrounded by double quotes), and the file access mode of "w", and after you've written out your text, fclose(filePointerName), the file.

If you mean export your C text file, in Word (the editor Word), format, that can't be done at all easily, because that format is proprietary, and changes from time to time. If this is what you want however, the way to do it is to get your C program's output as plain text, and then use Word to open the file as a text file. Now save it as a Word file document, and add any extra formatting that you want.

If by "word file" you mean a text file, just use fopen() with the name of the file (surrounded by double quotes), and the file access mode of "w", and after you've written out your text, fclose(filePointerName), the file.

If you mean export your C text file, in Word (the editor Word), format, that can't be done at all easily, because that format is proprietary, and changes from time to time. If this is what you want however, the way to do it is to get your C program's output as plain text, and then use Word to open the file as a text file. Now save it as a Word file document, and add any extra formatting that you want.

Well maybe I dont understand or what you said or I couldnt explain myself corrrectly but ill give a bit details because I need to fin this program for someone and the only thing I cant find is printing:).

I got a lot of scanf's taking some values and strings from user and after that my program making some calculations thats not the problem. After that using printf I show the all the result of the calculations of my calculations but it needs to be printed on a MS word document not on command window but I cant find it anywhere is the fopen the solution. How can I deal with the problem?

Regards

All you have to do is redirect stdout to a file. For example if the name of your program is myprog then on the command line or in a batch file myprog >myfile.txt With that, all the stuff that is printed with printf() statements will be directed into the text file instead of on the command line window.

although no very technical but
i think myprog >myfile.doc would be more correct since the calculation is to be posted onto something like <MSWord file>

That will not create an MS-World document file, but just a plain text file. The *.doc file is normally MS-Word file format, not text file format. Don't confuse people by naming file with incorrect or non-standrd extensions.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.