Jump to content
  • Advertisement
Sign in to follow this  
HeyHoHey

stringstream question

This topic is 4198 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i started learning about string stream and i was trying to make something to better understand/get used to it. i keep getting errors though what am i doing wrong?
#include <iostream>
#include <string>
using namespace std;

int main()
{
   string adress;
   int whereulive;
   
   cout<<"What is your full adress?\n";
   getline (cin, adress);
   stringstream(adress) >> whereulive;
   cout<<"I know where you live.\n";
   cin.get();
   cout<< whereulive;
      }

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by HeyHoHey
i keep getting errors though what am i doing wrong?

You are making errors.

If you want to know how to fix the errors, you could start by telling us what the errors are. (And in general, it also never hurts to explain what you're trying to do)

Always make it easy for people to answer your questions.

Share this post


Link to post
Share on other sites
Your example doesn't make much since...

Look at this...

std::string streetname = "Oak St.";
int addressnumber = 1500;

std::stringstream fullAddress;
fullAddress << addressnumber << " " << streetname;

std::cout << "You live at: " << fullAddress.str() << std::endl;



This would output "You live at: 1500 Oak St.".

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!