Monday, January 16, 2012

sleep function in c program !



hmm while working with the loops, that is so fast.. that just give us  the final output !! but if we want to put some delay in that so that
user can c that how the process is going , and that ll make ur code  looks different from the other regular codes. so try to use that(if u
want) in ur code.
for that just put :- sleep(1000)
thats it, now it will delay the process by 1sec. and start again !
Example :-
int main()
{
int i;
for(i=1;i<=10;i++)
{
//print the number
printf(“%d \n”,i);
//delay for 1sec.
sleep(1000);
}
getch();
}
have a happy coding!

No comments: