Thread: how?

  1. #1
    Unregistered
    Guest

    Lightbulb how?

    is it possible to make a dos program that
    writes
    "WELLCOME"
    letter after letter
    on the exact same spot!


    ..............................................
    ..............................................
    please help!
    if u know what i mean?

  2. #2
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,263
    yes use the gotoxy function at the bottom of the FAQ, to return the cursor to the last position each letter that is typed.

    http://www.cprogramming.com/boardfaq.html
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    479
    i didn't get that!

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    380
    #include <windows.h>
    #include <dos.h>
    void gotoxy(int x, int y)
    {
    COORD coord;
    coord.X = x;
    coord.Y = y;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_H ANDLE), coord);
    }


    int main()
    {
    char msg[] = "FAQ";
    int count = 0;
    while(msg[count] != '\0')
    { gotoxy(1,1);
    putch(msg[count++]);
    sleep(1);
    }
    }

  5. #5
    Registered User
    Join Date
    Dec 2001
    Posts
    479
    doesn't work when i compile!

  6. #6
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,263
    what about it doesn't work?

    here's a revised one?

    Code:
    #include <windows.h> 
    #include <stdio.h>  // need this header
    
    void gotoxy(int x, int y) 
    { 
        COORD coord; 
        coord.X = x; 
        coord.Y = y; 
        SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord); 
    }
    
    
    int main() 
    { 
        char msg[] = "FAQ"; 
        int count = 0; 
        while(msg[count] != '\0') 
        { 
            gotoxy(1,1); 
            putch(msg[count++]); 
            sleep(1); 
        } 
        return 0; // and you forgot the return.
    }
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  7. #7
    Registered User
    Join Date
    Aug 2001
    Posts
    380
    #include <stdio.h> // need this header


    It compiled without that header using borland 4.5 ok. Seeing you left the sleep() in and took out dos. Is it now located in the windows.h?

  8. #8
    Registered User
    Join Date
    Oct 2001
    Posts
    375
    You could also use:

    printf("W\be\b\l\bc\b\o\bm\be\r");

    Won't look like much because it prints each letter over each other.

    \b is backspace. \r is a return without a newline (cursor ends up at beginning of line).
    Allegro precompiled Installer for Dev-C++, MSVC, and Borland: http://galileo.spaceports.com/~springs/

  9. #9
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,263
    >It compiled without that header using borland 4.5 ok.

    probably would in MSVC also that doesnt mean its right...

    >Seeing you left the sleep() in and took out dos. Is it now located in the windows.h?

    eh..um..woops...

    there is a Sleep() function in windows.h but the truth is i forgot to put the right header for it.

    it is rather compiler dependant

    _sleep() is in stdlib.h in MSVC
    _sleep() is in unistd.h in Code Warrior
    sleep() is in dos.h? in Borland 4.5

    my mistake sorry.
    Last edited by no-one; 01-24-2002 at 12:54 AM.
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

Popular pages Recent additions subscribe to a feed