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 6699203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:40:03+00:00 2026-05-26T06:40:03+00:00

Maybe I’m missing something, but I’m having a lot of trouble finding any information

  • 0

Maybe I’m missing something, but I’m having a lot of trouble finding any information on how to how to read from an iostream (std::iostream& stream). Is there a way I can convert it to a string or similar?

For clarification this is (what I’m basically trying to do, for example):

std::stringstream ss("Maybe I'm missing something \n but I'm having a lot of trouble finding any information on how to how to read from an iostream.");
readStream(ss);

void readStream(std::iostream& stream)
{
    std::string out;
    stream >> out;
    // Do some stuff with the string
}

This seems to work, but out will be equal to "Maybe" rather than the full string.

  • 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-26T06:40:04+00:00Added an answer on May 26, 2026 at 6:40 am

    You read from an iostream the same way you would if you were using cin.

    stream >> varName;
    

    Crazy syntax yes, but that’s what the makers of streams decided to do.

    You can also use get and getline if your reading to strings. Get will get the next character or a specified buffer of characters, and getline will go to the next newline.

    getline(stringName);
    

    You can read more on this here: http://cplusplus.com/reference/iostream/iostream/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Maybe this is something I am just missing, but is there any way to
Maybe I am missing something entirely simple here, but in any new windows form
Maybe I'm missing something obvious, or maybe something sinister is happening, but this seems
Maybe I am missing something, but they seem similar. If you use for example...
Maybe this question should be easy, but it is not. I have read Problem
Maybe I'm missing the obvious but how do I (or can I) add an
maybe a few others already asked that but I couldn't find any answer to
Maybe I misunderstood the layout_weight parameter but I can't get it why something like
Maybe a facepalm for you guys, but as a SQL query newbie, I'm having
Maybe my question is silly. But when I change from normal version to EE

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.