I want to use miliseconds for my program in c, but there was an error. Basicly im trying to do a halfsecond sleep between between the command.
My code :
#include <stdio.h>
#include <cs50.h>
#include <unistd.h>
int msleep(unsigned int tms)
{
return usleep(tms * 1000);
}
int main(void)
{
int i = get_int("Choose a number.\n");
for (int a = i; a >= 1; a--)
{
printf("%d\n", a);
sleep(500);
}
{
printf("blast off!\n");
}
}
My error :
clang -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wshadow Coding.c -lcrypt -lcs50 -lm -o Coding
Coding.c:7:10: error: implicit declaration of function 'usleep' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
return usleep(tms * 1000);
^
1 error generated.
<builtin>: recipe for target 'Coding' failed
make: *** [Coding] Error 1
Thank you