# how?

This is a discussion on how? within the Game Programming forums, part of the General Programming Boards category; is it possible to make a dos program that writes "WELLCOME" letter after letter on the exact same spot! .............................................. ...

1. ## how?

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

..............................................
..............................................
if u know what i mean?

2. 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

3. i didn't get that!

4. #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. doesn't work when i compile!

6. 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.
}

7. #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. 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).

9. >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.