C programming How do I get numbers (or data) from a file (.txt) and write things into a file? I need to get data using loops but i'm not sure how to do.
Assuming that if you are doing file I/O you understand loops, you need to create a file pointer and assign it a value. Then you write to/read from that stream.
You can use EOF or the \n char as an indicator you've reached the end of the file or end of the line. Check here for some examples: http://www.cprogramming.com/tutorial/cfileio.html
thanks i will try this. I have an execute file (sample) that i need to write code for it. Do you have time to give it a look and give me some hints, if that's ok?
If it is something you would like reviewed then it is always a good idea to include it in your question. I am heading out the door right now but could look at it in a few hours and offer input if you'd like.
all right, anytime will do. to test the exe file, you will need to create a new txt file in the same folder (name it 123.txt for example), then run the .exe, then type "numbers.dat", then "123.txt". The .exe will calculate with the input from "numbers.dat" and put it into "123.txt". writting the code for the .exe is what i need to do. Thanks in advance
Join our real-time social learning platform and learn together with your friends!