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

  • SEARCH
  • Home
  • 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 6025623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:19:39+00:00 2026-05-23T04:19:39+00:00

Like I have a stringstream variable contains abc gg rrr ff When I use

  • 0

Like I have a stringstream variable contains "abc gg rrr ff"

When I use >> on that stringstream variable, it gives me "abc". How can I get the remaining string: " gg rrr ff"? It seems neither str() nor rdbuf() does this work.

  • 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-05-23T04:19:39+00:00Added an answer on May 23, 2026 at 4:19 am

    You can use std::getline to get the rest of the string from the stream:

    #include <iostream>
    #include <sstream>
    
    using namespace std;
    
    int main() {
            stringstream ss("abc gg rrr ff");
            string s1, s2;
            ss >> s1;
            getline(ss, s2); //get rest of the string!
            cout << s1 << endl;
            cout << s2 << endl;
            return 0;
    }
    

    Output:

    abc
    gg rrr ff
    

    Demo : http://www.ideone.com/R4kfV

    There is an overloaded std::getline function in which a third parameter takes a delimiter upto which you can read the string. See the documentation of std::getline:

    • std::getline
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem that I would like have solved via a SQL query.
I like to have a popup modal dialog that need to show the list
I have this function that converts an integer to a std::string: std::string intToStr(const int
I have a code like this int main() { std::stringstream oss; std::cerr.rdbuf( oss.rdbuf() );
I would like to have xpath, that obtains nodes, that don't have ancestor, which
I have a JComboBox and would like to have a separator in the list
I have an application where I would like to have mixed Java and Scala
I would like to have a reference for the pros and cons of using
I'd like to have a java.utils.Timer with a resettable time in java.I need to
I would like to have an iframe take as much vertical space as it

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.