Thread: typewriter

  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    109

    typewriter

    Is there a way to make text appear in dos like a typewriter (eg. one letter appears followed by anorther)

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Yes.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231

    Re: typewriter

    Originally posted by Granger9
    Is there a way to make text appear in dos like a typewriter (eg. one letter appears followed by anorther)
    That's a damn fine question.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Two replies and while both are excellent answers, you two really should answer what the OP means instead of what they actually say.
    Code:
    #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;
    }
    -Prelude
    My best code is written with the delete key.

  5. #5
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    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
    You just make things tooo easy Prelude..
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  6. #6
    Registered User CAP's Avatar
    Join Date
    May 2002
    Posts
    179
    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.
    -Microsofts Visual C++ Introductory Kit-
    Current Projects: Learning Everything C.

    Everyone has a photographic memory, some people just don't have any film.
    ______________________________

    When was the last time you went for a colon cleansing? Because quite frankly, you're so backed up with crap that it's spilling out your mouth

  7. #7
    Registered User moonwalker's Avatar
    Join Date
    Jul 2002
    Posts
    282
    here's another way:
    Code:
    void typeline()
    {
    	int i;
    	char line[]="-----------------------------------------------------------";
    
    	for (i=0; line[i]; i++)
    	{
    		printf("%c", line[i]);
    		delay(10);
    	}
    	printf("\n");
    }
    if delay doesn't work with your compiler, use
    this
    Code:
    void my_delay (int milliseconds)
    {
    	time_t end, now = clock();
    	for ( end = now + milliseconds; now < end; now = clock() )
    	continue;
    }
    and say my_delay(somenumberhere)

  8. #8
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    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.
    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
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  9. #9
    Registered User CAP's Avatar
    Join Date
    May 2002
    Posts
    179
    Thanks Hammer...that sounds somewhat familar . O well, I guess it is back to good old trial and error, thanks anyways.
    -Microsofts Visual C++ Introductory Kit-
    Current Projects: Learning Everything C.

    Everyone has a photographic memory, some people just don't have any film.
    ______________________________

    When was the last time you went for a colon cleansing? Because quite frankly, you're so backed up with crap that it's spilling out your mouth

Popular pages Recent additions subscribe to a feed