Here is a little C program that can do something like this. This assumes that your terminal uses '\r' to go to the beginning of the line instead of the next one. The flush is used because sometimes output is buffered, so it won't print until it is flushed:
#include <stdio.h>
#include <unistd.h>
int main(void)
{
printf("-");
fflush(stdout);
sleep(1);
printf("\r/");
fflush(stdout);
sleep(1);
printf("\r|");
fflush(stdout);
sleep(1);
printf("\r\\");
fflush(stdout);
sleep(1);
printf("\n\n");
}
In practice you wouldn't be sleeping, you'd be doing work in between the print statements. In practice you'd probably want to run work in a different thread than the one that prints this, or you'd need to interrupt your work regularly to do the print.
See Difference between \n and \r? for an overview of the difference between '\n' and '\r'.
As an alternative, if you have a terminal that supports VT100 codes you can use a function like this to move the cursor to a particular location where you can draw and re-draw the animation:
void gotoxy(int x, int y)
{
printf("%c[%d;%df", 27, y, x);
}
If neither of these approaches work you'll need to give more information about the system you are trying to do this on.