Jul 24, 2013 at 3:08am UTC
How can I get the first or second letter of a string?
Also how can I add letters to a string?
Thanks for your help!
Jul 24, 2013 at 3:25am UTC
the string obj has lots of functions. I know off hand that you can use obj.substr(a,b) which will return a letter. There's also a function to concatenate.
Jul 24, 2013 at 6:42am UTC
That's more complicated. Just use string[0] or string[1] to get the first and second letters. To add letters to the end, use a function.
Jul 24, 2013 at 8:15am UTC
std::string s( "ABCDEF" );
for ( std::string::size_type i = 0; i < s.size(); i++ ) std::cout << s[i] ;
std::cout << std::andl;
s += 'G';
std::cout << s << std::endl;