Hey c++,
I'm trying to write a code so that text is outputted one letter at a time (every 50 milliseconds or so - think of the "pokemon" style text). I am using Ubuntu and am quite new at programming (started early march) so I don't know all that much. But some help with explanation would be muchly appreciated.
void pokeprintf(constchar * de){
unsignedint ns = strlen(de);//we use this to find how long the string is.
for(unsignedint i =0;i<ns;i++){
putchar(de[i]);//we use this to print just the current character from the string.
fflush(stdout);//we use fflush to print the character to the screen now.
usleep(20000);//we use usleep to wait 20000 micro seconds or 20 milliseconds.
}
this is what I used in a small Zork clone i made to get a similar effect.
You'll have to include <unistd.h> and <string.h> though.
With just a little modification, this could also be used just like printf to print formatted data as well, but if you're a beginner, it might be better to wait a little bit until learning va_list's.