c++ - Why doesn't myString.at(myString.length()) work? -
i'm including <string>
library @ top of .cpp file when test out
cout<<mystring.at(mystring.length());
it should print out last letter of string, or @ least think should. compiler throws hissy fit , spits bunch of jargon @ me.
i'm used writing in javascript i'm not used to, well....having rules, me makes perfect sense return last character of string.
string indexes zero-based run [0..mystring.length()-1]. should use
mystring.at(mystring.length()-1);
to last character
Comments
Post a Comment