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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -