How without using gotoxy ?

This is a discussion on How without using gotoxy ? within the C++ Programming forums, part of the General Programming Boards category; If I wanted to print the word John for example on the screen starting at the end with the n ...

  1. #1
    Unregistered
    Guest

    Question How without using gotoxy ?

    If I wanted to print the word John for example on the screen starting at the end with the n and backing up each letter so next would be h, o, J but it would read correctly as John any ideas on how to go about this? The only thing I can think of is using gotoxy but it seems like there would be an easier way than a bunch of gotoxy's. You don't have to write it for me. I enjoy it more when I've done it, but a start or idea would be appreciated. thnks

  2. #2
    Registered User
    Join Date
    Feb 2002
    Posts
    591
    I am not sure if I understand you correctly but this might work

    Create an array with four chars and fill it with spaces

    Set the last char to n and print the whole array to the screen
    >___n<

    backstep four times (printf("\b\b\b\b"))

    and so on

    You probably want to add some delay in there to so that the user actually see that you are doing it from the end.
    Last edited by Barjor; 07-17-2002 at 09:07 AM.

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    27
    Hi,
    One way is to print a dummy string with all spaces. Then fill the dummy string starting at the right end and printing it again.
    You will have to use gotoxy(...) so the dummy string prints in the same position each time.

    Dont forget that the dummy must have /0 as its last char.
    If the dummy string is char dummy[5] (enough to hold "John),
    then start filling at dummy[3] and end at dummy[0].

    Hope this helps.
    Pappy
    You learn something new everyday.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What is gotoxy??
    By Beachblue in forum C Programming
    Replies: 6
    Last Post: 11-23-2008, 01:24 AM
  2. Tic Tac Toe movement
    By $l4xklynx in forum Game Programming
    Replies: 4
    Last Post: 11-06-2008, 07:22 PM
  3. gotoxy(); help!!
    By clique in forum C Programming
    Replies: 2
    Last Post: 10-07-2008, 05:08 AM
  4. Want to see if I am using gotoxy the right way ...
    By o0obruceleeo0o in forum C++ Programming
    Replies: 5
    Last Post: 04-22-2003, 05:17 PM
  5. Is gotoxy ansi?
    By MeneLaus in forum C Programming
    Replies: 2
    Last Post: 05-18-2002, 03:48 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21