I am working on my Final Project and I need to use the nanosleep function which suspends my program for a specified number of seconds. I tried to test this function first before using it in my actual program I get a compilation error :
test.c:12:3: error: implicit declaration of function 'nanosleep' is invalid in C99 [-Werror,-Wimplicit-function-declaration] nanosleep(t, t);
What's the problem I included time.h and still.. here is my code :
#include<sys/time.h>
#include<stdio.h>
int main(void)
{
struct timespec t;
t.tv_sec = 0;
t.tv_nsec = 1000000000;
for (int i = 0; i < 30; i++)
{
printf("%d\n", i);
nanosleep(t, t);
}
}
Note: I tried #include as well