Scrambling words (string2.cpp)Scrambling words (string2.cpp)
input:Hello world!input:Hello world!
output:olleH !dlrowoutput:olleH !dlrow
now, guess the input input ;-)now, guess the input input ;-)
output:gnirtS ssalc egasu elpmaxeoutput:gnirtS ssalc egasu elpmaxe
getline(stream, string)getline(stream, string)
inputs whole line, including and discarding EOLinputs whole line, including and discarding EOL
returns false after EOFreturns false after EOF
third argument is a line delimeter, defaults to ‘\n’third argument is a line delimeter, defaults to ‘\n’
access to string elementsaccess to string elements
operator[] – fast, no range checksoperator[] – fast, no range checks
method at() – slow due to checking of rangesmethod at() – slow due to checking of ranges
size() – for all STL containers, length() – traditionally for stringssize() – for all STL containers, length() – traditionally for strings
nobody is perfect: sizeof() does not work like for fundamental typenobody is perfect: sizeof() does not work like for fundamental type