Advertisement Jump to content
Sign in to follow this  

I am surprise stream not support the string?

This topic is 4990 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/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
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,


Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!