problem with string extraction

This is a discussion on problem with string extraction within the C++ Programming forums, part of the General Programming Boards category; I am trying to extract the first two characters from a string using getline, is this possible or how can ...

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    76

    problem with string extraction

    I am trying to extract the first two characters from a string using getline, is this possible or how can I do the extraction?
    Last edited by robasc; 10-20-2006 at 02:08 AM. Reason: title error

  2. #2
    System.out.println("");
    Join Date
    Jan 2005
    Posts
    84
    Can't you use getline to get the string and then just access the first two characters by saying:


    Code:
    stringName.substr(2);
    http://www.cppreference.com/cppstring/substr.html

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    7,319
    Or, if you don't want to get the entire line from the stream, just call get() twice to get two characters. Is there a reason you think you need to use getline?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 04:30 PM
  2. C++ ini file reader problems
    By guitarist809 in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2008, 06:02 AM
  3. Replies: 8
    Last Post: 04-25-2008, 02:45 PM
  4. Custom String class gives problem with another prog.
    By I BLcK I in forum C++ Programming
    Replies: 1
    Last Post: 12-18-2006, 02:40 AM
  5. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 12:56 PM

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