Thread: using char with .substr()

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

    Unhappy using char with .substr()

    I'm trying to use string variables with the fstream getline() and getting a conversion error.

    I need to use fstream for file input, but I also need to allow for spaces in my variables. the file I am calling is a fixed length file, so when I determine my variables from the file call it seperates the variables at any white space it encounters.

    if I use getline, I can't seperate the different variables according to the fixed lengths, can I?

    I tried using the .substr() and keep getting conversion errors?

    Please help, this is driving me nuts!
    I'd like to put Murphy and his laws in headlock sometimes!

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    One solution is to read in via std::getline(). Analyze the string object via, for example, find().

    Kuphryn

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    If you need more specific help, then you need to post an example of the file you're reading (assuming it isn't a binary file) and post the code that reads the file and parses the data.

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ ini file reader problems
    By guitarist809 in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2008, 06:02 AM
  2. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 09:42 PM
  3. Sorting Linked Lists
    By DKING89 in forum C Programming
    Replies: 6
    Last Post: 04-09-2008, 07:36 AM
  4. Passing structures... I can't get it right.
    By j0hnb in forum C Programming
    Replies: 6
    Last Post: 01-26-2003, 11:55 AM
  5. String sorthing, file opening and saving.
    By j0hnb in forum C Programming
    Replies: 9
    Last Post: 01-23-2003, 01:18 AM