• Advertisement
Sign in to follow this  

I am surprise stream not support the string?

This topic is 4657 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

Advertisement
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
Sign in to follow this  

  • Advertisement