Is this what you were thinking of? I changed the direction of the rotating word to the way you would probably read it, right to left rotation, and the word scrolls from the left of the screen, to the right, then back to left, etc, until you quit the program.
// Rotate.cpp : main project file.
#include <iostream>
#include <string>
#include <Windows.h>
usingnamespace std;
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
COORD CursorPosition;
void gotoXY(int x, int y);
int main()
{
string rotating_string = "moving...";
int len = rotating_string.length();
char letter_holder;
do
{
for (int m=4;m<70;m++)
{
for (int o=0;o<len;o++)
{
gotoXY(m,13);
cout << rotating_string << " ";
Sleep(200);
letter_holder = rotating_string[0];
for( int x=0;x<len;x++)
{
rotating_string[x] = rotating_string[x+1];
}
rotating_string[len-1] = letter_holder;
}
}
for (int m=70;m>3;m--)
{
for (int o=0;o<len;o++)
{
gotoXY(m,13);
cout << rotating_string << " ";
Sleep(200);
letter_holder = rotating_string[0];
for( int x=0;x<len;x++)
{
rotating_string[x] = rotating_string[x+1];
}
rotating_string[len-1] = letter_holder;
}
}
} while(true);
gotoXY(25,24);
return 0;
}
void gotoXY(int x, int y)
{
CursorPosition.X = x;
CursorPosition.Y = y;
SetConsoleCursorPosition(console,CursorPosition);
}
EDIT: If you're wanting to use a longer string for the moving marque, just change the for loops to..
1 2 3 4 5 6
for (int m=4;m<80-(len+1);m++) // Left to right on screen
and
for (int m=80-(len+1);m>3;m--) // Right to left
// This way, the end of the string will stop at the edge of the screen and then start reversing direction
// whithout messing up the rest of the screen layout. And change the 80, to however far distance you
// want the text to scroll up to..
Sadly, no this is not what I meant. I should have been more specific. I want the words "moving..." to start at the right of the display screen and slide all the way to the left without cutting off and starting again.
from the above code. That part was to move the text from left to right. Then all you have left would be right to left. After it finishes, it'll start back on the right side again, moving left.