I_lOVE_ROMAN's blog

By I_lOVE_ROMAN, history, 17 months ago, In English

I have a string which is empty initially.Then I added characters to it.

string s="";
s=s+'a';

it works fine in my pc but getting error in codeforces submission because it prints garbage at the end of hathe printed string.

Same things happen I use vector of char.In that case I use push_back method to add chars.But it still prints garbage in codeforces submission.

vector<char>vc;
vc.push_back('a')

Why is that happening? /predownloaded/42/08/4208fdc2b1a8d618adc8327184077c6b4baa0b60.png

  • Vote: I like it
  • -5
  • Vote: I do not like it

»
17 months ago, # |
Rev. 3   Vote: I like it +5 Vote: I do not like it