Sign in to follow this  
derek7

I am surprise stream not support the string?

Recommended Posts

I/O streams do support std::string.


std::string str1 = "Hello, World!";
std::cout << str1 << std::endl;


will work just fine.

Share this post


Link to post
Share on other sites
Quote:
Original post by derek7
when I string str1; cout<<str1;not work.



Are you using Dev-C++? If you have it set to not produce a console window, it skips out the cout<< statements, because they're console functions.

I only just discovered that when I was trying your code. I had the console window switched off, and it just jumped to a system("pause"); statement I'd put in, instead of doing cout<<str1<<endl.

I've been working on SDL games so I didn't need a console window, therefore it was switched off.


We've both learnt something :)

Hope to have helped,

ukdeveloper.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this