Find the answer to your Linux question:
Results 1 to 4 of 4
does anyone know how to make text print slowly to the screen? like in the old text games? -ZAc-...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux User zacam87's Avatar
    Join Date
    Dec 2004
    Location
    Viriginia
    Posts
    284

    making text print slowely


    does anyone know how to make text print slowly to the screen? like in the old text games? -ZAc-
    I can imagine a perfect world, a world without hate, a world without war. Then I can imagine us attacking that world because they\'d never expect it.

  2. #2
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    I'm not sure exactly how you want the text to print. Are you referring to something like this?
    Code:
    #include <stdio.h>
    #include <unistd.h>
    #include <stdlib.h>
    
    int main(int argc, char **argv) {
        if(argc < 2) {
            printf("usage: %s TEXT\n", argv[0]);
            exit(1);
        }
        for(; *argv[1]; argv[1]++) {
            putc(*argv[1], stdout);
            fflush(stdout);
            usleep(250000);
        }
        putc('\n', stdout);
    }

  3. #3
    Linux User zacam87's Avatar
    Join Date
    Dec 2004
    Location
    Viriginia
    Posts
    284
    yea! like that.. is there a line i can add to my code that will make it print liek that?
    I can imagine a perfect world, a world without hate, a world without war. Then I can imagine us attacking that world because they\'d never expect it.

  4. #4
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    Well, couldn't you change the function name, stick it in a header file, and #include that file?

    Then you could just call that function...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •