I’m trying to make a simple progress bar like FreeBSD does in its booting screen , displaying / , | , \ , – recursively , but the following code got now output at all
#include <stdio.h>
#include <unistd.h>
int main ( int argc , char **argv )
{
char arrows[4] = { '/' , '|' , '\\' , '-' };
int i = 0;
while (1)
{
printf ( "%c" , arrows[i] );
if ( i > 3 )
i = 0;
else
i ++;
sleep (1);
printf ( "\b" );
}
return 0;
}
You do not flush the output, so it will only be buffered and not flushed to the terminal until the buffer is full.
Add the following line after the first
printf: