How can i move a text in C??

anyone knows how to move a text in C??

if your watching news, it is like the text below ur TV set...

plz help....



  • Here's one way to have text crawl across the bottom:

    #include /* added to provide for gotoxy() function

    /* function defined because gotoxy() is not standard */
    void gotoxy(int x, int y)
    COORD coord;
    coord.X = x;
    coord.Y = y;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);

    int main(int argc, char *argv[])
    char cText[300];

    strcpy(cText, " ");
    strcat(cText, "This is the message to have crawl across the bottom of your screen. ");
    strcat(cText, " ");

    int d, i, j, tl = strlen(cText)-80;

    for (i=0;i<tl;i++)
    for (j=0;j<80;j++){
    gotoxy(j, 24);
    printf("%c", cText[i+j]);
    for (d=0;d<200000;d++); /* delay */

    return 0;

    You will have to change the delay value "d<200000" to achieve your desired speed. But, this should get you started...

    Take Care,
  • for (d=0;d<200000;d++);

    Never ever write delays like this. The time turns entirely CPU dependant and the program will occupy CPU resources needlessly on top of it.

    A classic bug like the one above was found in the old Pacman game for 80286. When 386 was released, the game turned very fast, and when 486 was released it turned unplayable, since the figures were moving at the speed of light.

    The correct way is to use the Sleep() function in windows.h.
  • Thanks Lundin,

    I agree with you about the delay, but when I try the sleep() function it defaults to seconds instead of milliseconds. I didn't pursue why. Is there a way to call the windows.h function over whatever one is being called now?

    Since sleep() didn't work the way I wanted it to, I figured the OP could at least get an idea of how to perform the crawl using the delay loop, but I should have added a caveat.

    Thanks again.

    Take Care,
  • wajihwajih lahore

    Can yu tell mee exactly how to move the text on the output of screen in c a short wcode sample ?????????ple ?????????****

  • wajihwajih lahore

    can yu tell mee exactly how to move the cursor on the output of the screen in c language with a short code sample

  • Just depends on your platform.
    C's standard library just has printf() and related functions.
    Some consoles can be given control codes to fix colour
    using ascii escape sequences. Others can't. I don't know
    offhand which system the Windows DOS box supports.

    There are also functions which manipulate the console
    as a text raster (a matrix or grid of cells containing
    characters). Under UNIX, you access this through a library
    called curses. Under DOS, it's called conio.

    But text output is steadily getting fancier as it supports
    non-Latin characters, right to left languages like Hebrew,
    proportional fonts, different fonts, colour, different
    console settings, and so on.
    You just have to check what is available with your
    particular compiler.

  • How can you Transfer Text Messages from Android to Computer in a simple way? In case of data loss, copy text messages from Android phone to the computer is pretty necessary. To transfer easily, Android Transfer, a professional data transfer program, can help your Backup and Restore Android on Computer. No just text messages, but also photos, videos, contacts and more. With its help, you are also permitted to backup everything of your Android phone with 100% quality. So, it is truly an effective data manager for your Android device.

    Read more:
    How to Transfer Contacts from Outlook to Android

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!