I'm trying to program a simple "typewriter" effect in C, where text appears one letter at a time with a delay. Here's the function I have:
#include <stdio.h>
#include <unistd.h>
void typestring(const char *str, useconds_t delay)
{
while (*str) {
putchar(*(str++));
usleep(delay);
}
}
The problem is the text doesn't actually appear until a \n
is displayed. What am I doing wrong?