0

Below is the code, when it run shows a combination of back-slash and forward slash and by putting them together and printing them shows a stick rotating. The problem is that it is only rotating at a same position I want to move it back and forth in a line.

void run()
{
 while(1)
  {

                printf("\\");
                sleep(0.5);
                printf("\t");
                printf("\r");
                printf("|");
                sleep(0.5);
                printf("\t");
                printf("\r");
                printf("/");
                sleep(0.5);
                printf("\t");
                printf("\r");

  }
}
3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by MyrtleTurtle
0

You have to move it then. What you are doing is

output a character at the left edge of screen;
wait;
output a tab;
return to left edge;
repeat;

How can you put the character where you want it?

0

My compiler would not let me use sleep (with a small 's').
And...I always use larger numbers. I don't think your delay is very long. If you want a half-second delay:

Sleep(500);

You don't need the tab, if you want the stick to show up in the same spot each time (at the left). Or if you want it to show up in the middle of the screen somewhere, then put the tab after the return. Put one tab before the first line printed and omit the last tab.

If you want it to look like it's rotating, you'll need to add a horizontal line, won't you?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.