from text file to array

This is a discussion on from text file to array within the C++ Programming forums, part of the General Programming Boards category; Hello there, i'm writing a code of a program and i'm stuck with one thingy... i need to put the ...

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    14

    from text file to array

    Hello there, i'm writing a code of a program and i'm stuck with one thingy... i need to put the content of file to a char array... the content of file:
    Code:
    one(1) nine(9) five(5) two(2)
    how do i put only the words in to a array...because later i will have to go through all of them and search for a particular word? any suggestions?

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,471
    Quote Originally Posted by apisio View Post
    Hello there, i'm writing a code of a program and i'm stuck with one thingy... i need to put the content of file to a char array...
    Why not to use vector of strings instead?
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #3
    Registered User
    Join Date
    Nov 2009
    Posts
    14
    alright, how to i put it to a string then? will i have to change all the chars to strings?

  4. #4
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,471
    Quote Originally Posted by apisio View Post
    alright, how to i put it to a string then? will i have to change all the chars to strings?
    Have you read FAQ?

    For example Cprogramming.com FAQ > Separate a string into tokens? (C++)
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. reading a string from a text file into a 2d array
    By duelord in forum C++ Programming
    Replies: 2
    Last Post: 11-22-2009, 06:29 AM
  2. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  3. A bunch of Linker Errors...
    By Junior89 in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2006, 01:59 PM
  4. Replies: 3
    Last Post: 03-04-2005, 01:46 PM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21