Hiii,
I wanted to know how to put a delay of milliseconds or seconds at any step in a C program. On googling i came across sleep(), but its not a standard C funtion. Any suggestions?
AFAIK there is no such standard function for putting delay
u have to be platform specific in this case
#include "stdio.h"
#include "time.h"
int main(void){
struct timespec t;
t.tv_sec = 0;
t.tv_nsec = 500000000;
while(1){
printf("Hello world!\n");
nanosleep(&t,NULL);
}
return 0;
}
NOT THAT GOOD IN C .. This I have copied from somewhere else
There is also delay(int msec) function in dos.h.
Try using it. It works.
-----------------------------------------
Posted again:
-----------------------------------------
There is also delay(int msec) function in dos.h.
Try using it. It works.
^^ +1
just include <dos.h>
and u can use this function "delay()" anywhere in any standard C program.
Hai,
You can use delay(int n) defined in dos.h
are you looking in Debugginh case?
using Visual C++ you have more ease with debugging. Or use Geany and Mingw in Windows or Geany and gcc in Linux.
yes, delay() function works well, u can used it in drawing animation or displaying msg, like calculating result and then after delay display d result.
Instead of directly printing output.