Thread: could someone show me how to read in a string from a file...

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    25

    could someone show me how to read in a string from a file...

    and how to use strtok() to parse it up in c++. i am planning on using getline(). thank you in advance
    I Love Jesus

  2. #2
    Unregistered
    Guest
    there are several versions of getline() depending on which type of string you are using as a buffer to hold the input. The one for c_style strings has the prototype:

    streamName.getline(bufferName, maxSizeOfDesiredInput, terminatingChar)

    where bufferName is a valid c_style string with adequate memory allocated for maximum size of desired input, which is obviously the second parameter. terminatingChar can be any valid char and defaults to new line char if you don't specify one.

    I don't know the prototype for strtok() off the top of my head because I usually write my own parsing functions, glutton for punishment that I am.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. String issues
    By The_professor in forum C++ Programming
    Replies: 7
    Last Post: 06-12-2007, 09:11 AM
  2. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  3. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  4. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  5. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM