September 28th, 2012, 05:14 AM
How to store it after comparing ? I tried but its not storing in file.
Write a program which takes 10 integer numbers from user. Save all the positive numbers to one file, all the negative numbersto another file.
In this , I know after comparing numbers ,based on comparison condition ,we have to store it in respective positive and negative file.
I created 2 pointers for this 2 files.
I did the comparison part and as per the comparison inside it:
the syntax I used to create file is :
The file is being created but after that I am not able to do the storing part.
To store I used this syntax:
Can somebody guide me?
September 28th, 2012, 05:35 AM
September 28th, 2012, 12:32 PM
You'd do better with
Please read the manual about putc. See if you can figure out why it didn't work.
[edit---> bad code cited in following message removed Sorry that this wrecks the thread but on the other hand, bad code in the thread is also bad.]
Last edited by b49P23TIvg; September 28th, 2012 at 01:53 PM.
[/code] are essential for python code and Makefiles!
September 28th, 2012, 01:25 PM
fprintf() returns the number of characters printed. Your format string has 2 directives. The first directive ("%d") causes at least 1 character to be printed; the second directive (" ") causes exactly 1 character to be written; so, barring output errors, the total number of characters written is 2 or more ... and that is the return value of the function.
Originally Posted by b49P23TIvg
You're testing if it's different than 1. Barring output errors it is guaranteed to be different and the output of your code is to always print "\nYou computer is hosed.\n" to the standard error stream.
Comments on this post