i have

#include <stdio.h>

int main()
{
int a;
int b;
    a = 3;
    b = 30;
    while (a < b)
    {
    printf("%d\n crap .....", a);
    a = a + 1;
    }
return 0;

}

i got output

crap .....4
crap .....5
crap .....6
crap .....7
crap .....8
crap .....9
crap .....10
crap .....11
crap .....12
crap .....13
crap .....14
crap .....15
crap .....16
crap .....17
crap .....18
crap .....19
crap .....20
crap .....21
crap .....22
crap .....23
crap .....24
crap .....25
crap .....26
crap .....27
crap .....28
crap .....29

what about if i want

crap.......1

and after one second

crap.......2

Recommended Answers

All 5 Replies

Please try to search the forum with the required keyword and then post if your query here.

Maybe you should look here for solution
http://www.daniweb.com/techtalkforums/thread56763.html

Just integrate the sleep funtion given there below the display stmt in the while loop and thigs will work out fine for you.

yes but how to enter sleep in this file

#include <stdio.h>

int main()
{
int a;
int b;
    a = 3;
    b = 30;
    while (a < b)
    {
    printf("%d\n crap .....", a);
    a = a + 1;
    }
return 0;

}

sory im complete noob

yes but how to enter sleep in this file

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

int main()
{
int a;
int b;
    a = 3;
    b = 30;
    while (a < b)
    {
    printf("%d\n crap .....", a);
    a = a + 1;
    Sleep ( 2000 ) ;
    }
return 0;

}

But the thing is that the above code will work only on windows.

I havent as such personally worked on Linux but if you using Linux (like your avatar says i think) then try using the usleep (2000) function (notice the lowercase "s") here the parameter passsed is time in microseconds.

Also dont forget to include the #include <unistd.h> instead of the windows header.

#include <stdio.h>
#include <unistd.h>

int main()
{
int a;
int b;
    a = 3;
    b = 30;
    while (a < b)
    {
    printf("%d\n crap .....", a);
    a = a + 1;
    usleep ( 2000 ) ;
    }
return 0;

}

Hope it helped, by.e

yes that realy helped

thank you very much

The pleasure is all mine :D
Just keep up the good work.

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.