using char with .substr()

This is a discussion on using char with .substr() within the Windows Programming forums, part of the Platform Specific Boards category; I'm trying to use string variables with the fstream getline() and getting a conversion error. I need to use fstream ...

  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,630
    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, 10:55 AM
  5. String sorthing, file opening and saving.
    By j0hnb in forum C Programming
    Replies: 9
    Last Post: 01-23-2003, 12:18 AM

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