0

i want to know the code in C language
when i will compile the program the character will delay printing in the display.
Please help.

thanks.

4
Contributors
5
Replies
6
Views
4 Years
Discussion Span
Last Post by Gonbe
0

what compiler are you using?
check the sleep function from the unistd.h library if your using linux or windows.h for windows

0

Try something like this:

#include <stdio.h>
#include <windows.h>

const int DELAY_IN_MICROSECONDS = 100;

int main (void)
{
    char symbol = 'a';

    while (1)
    {
        putchar(symbol++);

        if (symbol > 'z')
        {
           symbol = 'a';
           putchar('\n');
        }

        fflush(stdout);
        Sleep(DELAY_IN_MICROSECONDS);
    }

    return 0;
}

More information about Windows' Sleep function here: MSDN

Edited by pritaeas: Fixed your link. The editor has trouble with links containing parenthesis.

0

const int DELAY_IN_MICROSECONDS = 100;
Sleep(DELAY_IN_MICROSECONDS);

Sleep() takes a parameter that represents milliseconds, not microseconds. I just wanted to point that out in case readers don't study the documentation you linked to closely enough, and then find Sleep() doesn't have the granularity they want.

Edited by deceptikon

0

Sleep() takes a parameter that represents milliseconds, not microseconds. I just wanted to point that out in case readers don't study the documentation you linked to closely enough, and then find Sleep() doesn't have the granularity they want.

Woops yeah, meant to type milliseconds. Thanks for the heads up.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.