i have a string and i need to add a number to it i.e a int. like:
string number1 = ("dfg"); int number2 = 123; number1 += number2; this is my code:
name = root_enter; // pull name from another string. size_t sz; sz = name.size(); //find the size of the string. name.resize (sz + 5, account); // add the account number. cout << name; //test the string. this works... somewhat but i only get the "*name*88888" and... i don't know why. i just need a way to add the value of a int to the end of a string
resizeis a char, and resize uses it repeatedly to fill in any extra space it creates at the end of the string. In your caseaccountis equal to 56 (mod 256), so you've passed the character8.