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.

Recommended Answers

All 5 Replies

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

its for the compiler C and operating system is Windows.

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

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.