What is a C header file?

C Sleep function header file help?

  • I cant seem to find the right header file, apart from the obvious header files, the rest dont work, here is the exact code ( it was a test ) : #include <time.h> #include <stdio.h> #include <sys/time.h> #include <time.h> #include <stdlib.h> #include <stdio.h> #include <conio.h> #include <unistd.h> int main() { printf("This is Msg_1 \n"); sleep(1000); // here is my problem :( printf("This is Msg_2 after 1 second......."); getch(); return 0; } what header files do i need ? OS : Windows 7 Home Premium x86 Computer Type : x86

  • Answer:

    #include <stdio.h> #include <windows.h> /* For Sleep() */ int main(void) {         printf("This is message one\n");         Sleep(1000);         printf("This is message two\n");         return 0; }

Brad Cross at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

It's more compiler dependent than OS dependent but you will find it in GCC in unistd. I'm writing this on Slackware Linux and I just went looking and got: bash-4.1$ grep sleep /usr/include/unistd.h /* Make the process sleep for SECONDS seconds, or until a signal arrives SIGALRM signal while inside `sleep' call, the handling of the SIGALRM error, but if `sleep' returns SECONDS, it probably didn't work. extern unsigned int sleep (unsigned int __seconds); extern int usleep (__useconds_t __useconds); bash-4.1$ Grep is a program for UNIX and Linux which finds a string in a given file. You might search unistd.h in your compiler, but it can be in other files.

You dont need repeats of those headers, for one. Beware with conio.h. If you are going to use it, use it for its purposes: roguelike gaming. Otherwise, all you need to do is: Sleep(x); with a capital S. Otherwise it wont work. Hope this helped!

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.