When I write a program containing delay the compiler shows the error E:\c programms\ma.o:ma.c|| undefined reference to `delay'| ||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
How to use delay() function in c using codeblocks 13.12(mingw)?
68.2k Views Asked by Sri Harsha At
3
There are 3 best solutions below
0

You can use your own created delay() function for delaying statements for milliseconds as passed in parameter...
Function Body is below.....
#include<time.h>
void delay(unsigned int mseconds)
{
clock_t goal = mseconds + clock();
while (goal > clock());
}
Just Paste the above code in your C/C++ source file...
example program is below...
#include<stdio.h>
#include<time.h>
void delay(unsigned int mseconds)
{
clock_t goal = mseconds + clock();
while (goal > clock());
}
int main()
{
int i;
for(i=0;i<10;i++)
{
delay(1000);
printf("This is delay function\n");
}
return 0;
}
Try this function: