Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8604849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:40:44+00:00 2026-06-12T02:40:44+00:00

ALL, Here is my code: std::string version = curl_version(); version = version.substr( version.find( ‘/’

  • 0

ALL,
Here is my code:

std::string version = curl_version();
version = version.substr( version.find( '/' ) + 1 );
int min, max;
int pos = version.find( '.' );
std::stringstream stream( version.substr( 0, pos ) );
version = version.substr( pos + 1 );
stream >> max;
pos = version.find( '.' );
stream.str( version.substr( 0, pos ) );
stream >> min;

I’m just reusing the same stream object but for some reason min variable is not assigned properly.

What am I missing?

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:40:45+00:00Added an answer on June 12, 2026 at 2:40 am

    The problem is that you can’t reuse the same stringstream object, try doing like this instead:

    std::string version = curl_version();
    version = version.substr( version.find( '/' ) + 1 );
    int min, max;
    int pos = version.find( '.' );
    std::stringstream stream( version.substr( 0, pos ) );
    version = version.substr( pos + 1 );
    stream >> max;
    pos = version.find( '.' );
    std::stringstream stream1( version.substr( 0, pos ) );
    stream1 >> min;
    

    It seems that when you shift (>>) out of a stringstream and it reaches eof (you can check by calling stream.eof()) a flag is set that prevents further shifting out even if you set (by calling str()) a new associated string object.
    To make it work, you have to call clear() before shifting out again.

    std::string version = curl_version();
    version = version.substr( version.find( '/' ) + 1 );
    int min, max;
    int pos = version.find( '.' );
    std::stringstream stream( version.substr( 0, pos ) );
    version = version.substr( pos + 1 );
    stream >> max;
    pos = version.find( '.' );
    stream.str( version.substr( 0, pos ) );
    str.clear();
    stream >> min;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

enter code here Hi All, I have a simple windows service application that connects
I'm using the code here and I want all the functions which call SDL
All my code is here,quite simple,and I don't konw where it goes wrong. Person
Here is ALL my code for this specific view controller. As the title of
Here is my code @Entity class Parent extends Person { @OneToMany(cascade = CascadeType.ALL, fetch
I've copied all the code from here but instead of looking like the sample
Here is my code: (Thank you MurifoX) <% random_bullets = Bullet.all %> <ul> <%
Here is the code: <?php //Starting session session_start(); //Includes mass includes containing all the
Here is te code: <?php //Starting session session_start(); //Includes mass includes containing all the
my sample code is here include 'simple_html_dom.php'; function get_all_links($url){ global $host; $html = new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.