Thread: reading .txt file

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    8

    reading .txt file

    the file is input.txt with a paragraph in it
    and i need to store each word into an array
    how would i go about doing this.
    plus i need to check if they are integers
    can anyone help?

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Do what you can first. When you get stuck, post your code so far, post what you can't get done, post any errors you have. Etc.

    Provide us as much information as you can so we can help you. We will not do your work for you.

    Use code tags, read the FAQ.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    8
    ok ok
    i dont know how to read it in.
    The "HOW TO C PROGRAM" lies i dont know what they are talking about

    hmm..
    i know how to read in set integers and stuff but i dont know how to go about it when i have to do strings, one at a time from a paragraph...

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    char buf[BUFSIZ] = {0};
    ... do stuff ...
    
    while( fgets( buf, BUFSIZ, inputFile ) != NULL )
         printf("The line read is:\n%s." buf );
    Enjoy.

    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    Registered User
    Join Date
    Mar 2003
    Posts
    8
    thanx

    i will probably post again later with code this time cuz i always screw up somewhere.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  4. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 03:58 PM