I'm using eclipse and I'm building a simple program, but I get an error saying function sleep could not be resolved
#include <time.h>
#include <stdio.h>
#include <conio.h>
#include <iostream>
using namespace std;
int main() {
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
printf("ciao");
sleep(20);
return 0;
}
I don't know if I need other libraries or something else. MinGW should be installed properly, so I have no idea
The sleep() function is defined by POSIX, not by the C++ standard.
If you're on a Unix-like system, you need
#include <unistd.h>
If you're not, then the sleep() function might not even be available.
Oh, and mixing cout << ... and printf() is probably not a good idea, and you don't need the #include <conio.h>.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With