Visual C++ - String Rotate
The source code for rotating a string is given on this page.
Source Code
void main()
{
char buf[] = "ABCD";
int sz = strlen(buf);
std::cout << buf << "\n";
for(int i = 0; i < sz; i++)
{
char ch = buf[0];
for(int j = 0; j < sz - 1; j++)
{
buf[j] = buf[j+1];
}
buf[sz - 1] = ch;
std::cout << buf << "\n";
}
}
Output
ABCD
BCDA
CDAB
DABC
ABCD
|