String rotation in C++