How to move a character from left to right on the console screen in C

1 Answer

0 votes
#include <stdio.h>
#include <string.h>
#include <unistd.h>   // for usleep()

int main() {
    const int width = 50;

    for (int x = 0; x < width; x++) {
        printf("\r%*c", x, '@');   // print x spaces then '@'
        fflush(stdout);
        usleep(80000);             // 80 ms
    }

    printf("\n");
    
    return 0;
}



/*
run:

                            @

*/

 



answered 2 hours ago by avibootz
...