2

My code is as follows:

#include <stdlib.h> #include <time.h> #include <unistd.h> #include <windows.h> int main() { printf("test"); usleep(1000000); printf("test"); return 0; } 

I am being told "error: 'usleep' was not declared in this scope". I am using the c free compiler if that makes a difference and am completely unsure of why this code is not compiling as all needed libraries are included.

9
  • 1
    Possible duplicate of implicit declaration of function usleep Commented Oct 22, 2019 at 19:45
  • errors: "EINVAL usec is not smaller than 1000000. (On systems where that is considered an error.)" Commented Oct 22, 2019 at 19:46
  • you can use Sleep(1000); Commented Oct 22, 2019 at 19:46
  • stackoverflow.com/a/40451160/215752 Commented Oct 22, 2019 at 19:47
  • 1
    Why #include <windows.h> if you are on a Unix system? Commented Oct 22, 2019 at 20:13

1 Answer 1

0

You need just to include:

#include <unistd.h>

Sign up to request clarification or add additional context in comments.

1 Comment

This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.