sscanf and c++!

Discussion in 'C++' started by Mike, Jun 8, 2004.

  1. Mike

    Mike Guest

    hey ...

    is there a better way in ansi c++ for parsing strings similar to how
    old c uses sscanf? a function that uses std::string instead of old char's.

    have seen some extensions like the boost library but I want to keep
    as standard as possible.

    thanks

    - mike -
    Mike, Jun 8, 2004
    #1
    1. Advertising

  2. "Mike" <> wrote in message
    news:...
    > hey ...
    >
    > is there a better way in ansi c++ for parsing strings similar to how
    > old c uses sscanf? a function that uses std::string instead of old char's.
    >


    You can use sscanf with strings

    sscanf(str.c_str(), ...);

    > have seen some extensions like the boost library but I want to keep
    > as standard as possible.
    >


    boost is not an extension, its a portable freely redistributable library.

    john
    John Harrison, Jun 8, 2004
    #2
    1. Advertising

  3. Mike wrote:
    >
    > is there a better way in ansi c++ for parsing strings similar to how
    > old c uses sscanf? a function that uses std::string instead of old char's.


    Look up istringstream.

    --
    Russell Hanneken

    Remove the 'g' from my address to send me mail.
    Russell Hanneken, Jun 8, 2004
    #3
  4. Mike

    Mike Guest

    sorry didnt mean an extension, library of course! will look into the
    istringstream ... thanks!

    > boost is not an extension, its a portable freely redistributable library.
    >
    > john
    Mike, Jun 9, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. pramod
    Replies:
    22
    Views:
    1,827
    Lew Pitcher
    Jan 6, 2004
  2. Andrej Hocevar
    Replies:
    1
    Views:
    479
    Nick Austin
    Aug 18, 2003
  3. pramod

    endianness and sscanf/sprintf

    pramod, Dec 31, 2003, in forum: C Programming
    Replies:
    22
    Views:
    775
    Lew Pitcher
    Jan 6, 2004
  4. zardoz
    Replies:
    82
    Views:
    5,023
    Paul Mesken
    Jun 4, 2005
  5. RSoIsCaIrLiIoA

    on fgets and sscanf and their bugs

    RSoIsCaIrLiIoA, Apr 20, 2006, in forum: C Programming
    Replies:
    7
    Views:
    1,542
    Richard Heathfield
    Apr 25, 2006
Loading...

Share This Page