C++ string not printed -


i have next code:

void addcontent ( const std::string& message ) {    std::string newmessage;     ( int = 0, remainder = textcapacity - currenttext; < remainder; i++ ) {       newmessage[i] = message[i];       std::cout << newmessage; //here nothing printed    } } 

but nothing printed.

only if change newmessage newmessage[i] good. , dont undestand why?

newmessage empty std::string. doing [i] accessing invalid memory. string empty, , you're writing invalid memory. that's recipe disaster, , you're (un)lucky it's not crashing on you.

i'm not sure message[i] is, want newmessage[i] = message[i]. might skip temporary newmessage variable , print out message[i] itself.


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -