Hi guys, my latest project at school is to create this "rolling banner" type thing where a string is outputted across the screen, going left.
Something like this:
Hello World!
ello world ! h
llo world ! he

By using the "Wait" function I can make it look like a sort of animation. My teacher advised me to resize the string to 80 as that is the length of the console. I've finally devised a way to do it, but I've run into an issue. The string moves from one line to the next, and it eventually runs out of space and the program crashes. How do I make it so that the string only moves on a single line?9000 is just an arbitrary number also. Any help is greatly appreciated! Heres the code:
Code:
#include<iostream>
#include<string>
#include<ctime>
#include<stdlib.h>
using namespace std;
void work(string s);
void Wait(double ms);
int main()
{
    string s;
    cout<<"Enter dat string: ";
    getline(cin,s);
    system("CLS");
    work(s);


}
void work(string s)
{
    int j=0,z=79,x=0;
    s.resize(80);
    for(int b=0;b<9000;b++){
    system("CLS");
    for(int i=j;i<s.length()-1;i++)
    {
        cout<<s.at(i);
        cout<<" ";
    }
    j++;
    Wait(.001);
    for(int k=z;k>0;k--)
    {
        cout<<" ";
    }
    z--;
    Wait(.001);
    for(int j=0;j<x;j++)
    {
        cout<<s.at(j);
        cout<<" ";
    }
    x++;
    Wait(.001);
    }
}
void Wait(double ms)
{
    clock_t endwait;
    endwait = clock () + ms * CLOCKS_PER_SEC ;
    while (clock() < endwait) {}
}