Help

Hi guys I need help with this code.. I need it to move it from left to right infinitely. this is my project/exam and my partner just bailed on me on the passing day. i have 2 project i'll post the other one after this. This is my code so far.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
  #include <iostream>
  #include <cstdlib>
  #include <string>
  #include <ctime>
  #include <iomanip>
  #include <windows.h>

  using namespace std;
  int main ()
  {
         string a;
         cout <<"Enter stringc : ";
         cin >> a;
         cout << '\n' << '\n' << '\n' << '\n';
         for(int x = 0; x <= 20; x++ ){
         Sleep(200);
         system("cls");
         cout <<"Enter String : ";
         cout << a;
         cout << '\n' << '\n' << '\n' << '\n';
         cout << setw(x)<< a;
}
         for(int y = 20; y <= 20; y-- ){
         Sleep(200);
         system("cls");
         cout <<"Enter String : ";
         cout << a;
         cout << '\n' << '\n' << '\n' << '\n';
         cout << setw(y)<<a;
}
        return 0;
}
I'll give you a hint, you should be able to figure out the rest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
#include <iomanip>
#include <windows.h>

using namespace std;

void moveLeft(char c);
void moveRight(char c);

int main()
{
    //press ESC to exit infinite loop
    moveRight('*');
    return 0;
}

void moveLeft(char c)
{
    system("cls");
    cout << "Move '" << c << "' to the left!";
    Sleep(200);
    if (GetAsyncKeyState(VK_ESCAPE))
        return;
    moveRight(c);
}

void moveRight(char c)
{
    system("cls");
    cout << "Move '" << c << "' to the right!";
    Sleep(200);
    if (GetAsyncKeyState(VK_ESCAPE))
        return;
    moveLeft(c);
}
Last edited on
@Skippy123
Welcome to cplusplus.com! The types of posts that you are writing do not ask questions very well. You give very tiny explanations of what the programs that you are working on are supposed to do. Please help us to help you. We would like to see you ask questions. Perhaps, point out sections of the code that are causing you trouble. Tell us what you have tried so far. Etc.
I would love to help you, but I need you to ask your questions the smart way:
http://www.catb.org/~esr/faqs/smart-questions.html
@fg109
Thank you very much for replying. and thank you for giving me a hint. I just started C++ and my teacher isn't very good in explaining. Im looking forward on taking pointers and learnings from you guys. Thank you.
Topic archived. No new replies allowed.