Thread: from text file to array

  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
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,794
    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?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    David J. Wheeler

  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
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,794
    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++)
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    David J. Wheeler

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, 07: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, 02:59 PM
  4. Replies: 3
    Last Post: 03-04-2005, 02: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