Is there a way to make text appear in dos like a typewriter (eg. one letter appears followed by anorther)
Printable View
Is there a way to make text appear in dos like a typewriter (eg. one letter appears followed by anorther)
Yes.
Quzah.
That's a damn fine question. :)Quote:
Originally posted by Granger9
Is there a way to make text appear in dos like a typewriter (eg. one letter appears followed by anorther)
Two replies and while both are excellent answers, you two really should answer what the OP means instead of what they actually say. ;)
-PreludeCode:#include <stdio.h>
#include <time.h>
static void pause ( int ticks )
{
clock_t end, current = clock();
end = current + ticks;
while ( current < end )
current = clock();
}
int main ( void )
{
int i;
char *text = "This is a test";
for ( i = 0; text[i] != '\0'; i++ ) {
(void)putchar ( text[i] );
pause ( 200 );
}
(void)getchar();
return 0;
}
You just make things tooo easy Prelude.. ;)Quote:
Originally posted by Prelude
Two replies and while both are excellent answers, you two really should answer what the OP means instead of what they actually say. ;)
<snip>
-Prelude
I get most of that...I think...but can someone explain in a little more detail how clock_t works, I have looked at it in my compilers index but it didn't help me all that much.
here's another way:
if delay doesn't work with your compiler, useCode:void typeline()
{
int i;
char line[]="-----------------------------------------------------------";
for (i=0; line[i]; i++)
{
printf("%c", line[i]);
delay(10);
}
printf("\n");
}
this
and say my_delay(somenumberhere)Code:void my_delay (int milliseconds)
{
time_t end, now = clock();
for ( end = now + milliseconds; now < end; now = clock() )
continue;
}
Quote:
Originally posted by CAP
I get most of that...I think...but can someone explain in a little more detail how clock_t works, I have looked at it in my compilers index but it didn't help me all that much.
Quote:
clock()
return the number of clock ticks used by the program
Synopsis:
#include <time.h>
clock_t clock(void);
Description:
The clock() function returns the number of clock ticks of processor time used by the program since it started executing. This can be converted to seconds by dividing by the value of the macro CLOCKS_PER_SEC.
Returns:
the number of clock ticks that have occurred since the program started executing
Thanks Hammer...that sounds somewhat familar ;) . O well, I guess it is back to good old trial and error, thanks anyways.