Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

nphuongsun93

  • 2 years ago

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.

  • This Question is Closed
  1. eSpeX
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    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.

  2. eSpeX
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    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

  3. nphuongsun93
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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?

  4. eSpeX
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    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.

  5. nphuongsun93
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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

  6. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Ask a Question
Find more explanations on OpenStudy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.