Array of Strings in C++ help ->

Discussion in 'C Programming' started by Mawhonic, Apr 20, 2010.

  1. Mawhonic

    Mawhonic

    Joined:
    Apr 20, 2010
    Messages:
    1
    Welp, I have this project in which I must read in the contents of file, specifically each word block by word block. And I can accomplish this well enough.

    I setup a string x;
    and then have a While loop:

    While(InFile>>x)
    {
    cout<< x <<endl;
    }

    This part of the project works fine. I can read the entire file and display it. But the next part has baffled me for a week. I want to read the file and retrieve each word string, but as x retrieves each string, I want to push the content of X into an array of strings (which in this case should contain each individual string word block of the file under each of its elements by the time the file has been traversed) And then I will hopefully be able to traverse that string array after the file has been read with a For Loop.

    So Recap:
    - read from a file >done
    - but how to push the strings of the file one by one into an array of strings which can be traversed later >not so done.

    And that's it, anybody have an idea? Your time is much appreciated.
     
    Mawhonic, Apr 20, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Venkat
    Replies:
    4
    Views:
    1,014
    Venkat
    Dec 5, 2003
  2. Kurt Krueckeberg
    Replies:
    2
    Views:
    730
    =?ISO-8859-1?Q?Ney_Andr=E9_de_Mello_Zunino?=
    Nov 17, 2004
  3. Rick

    Comparing strings from within strings

    Rick, Oct 21, 2003, in forum: C Programming
    Replies:
    3
    Views:
    395
    Irrwahn Grausewitz
    Oct 21, 2003
  4. Ben

    Strings, Strings and Damned Strings

    Ben, Jun 22, 2006, in forum: C Programming
    Replies:
    14
    Views:
    810
    Malcolm
    Jun 24, 2006
  5. Amit  Limaye
    Replies:
    4
    Views:
    470
    Phlip
    Apr 10, 2006
Loading...

Share This Page