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");

  }
}

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?

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.