The program is this :
Write a program which takes 10 integer numbers from user. Save all the positive numbers to one file, all the negative numbersto another file.
So,the coding will be compare all integers with 0 and save according in two different files right?
If I am right then how to store it in files?
Can we save it in already existed file?
or we have to create one then save it?
And what is the syntax to do this?
Iamateur
0
Junior Poster in Training
Recommended Answers
Jump to PostSo,the coding will be compare all integers with 0 and save according in two different files right?
Correct.
If I am right then how to store it in files?
See FILE* file handling functions (a tutorial is here).
Can we save it …
Jump to PostYou need to open both files before doing anything and keep them open until the program is done comparing numbers. Opening files is very time consuming, so just open once during the lifetime of the program.
open file1 open file2 start of loop and repeat 10 times …
All 8 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Iamateur
0
Junior Poster in Training
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Iamateur
0
Junior Poster in Training
Iamateur
0
Junior Poster in Training
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Iamateur
0
Junior Poster in Training
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.