Hi, basically, I am looking to put a pause into my program for about 1 second before doing a read. How can i do this??? i know is c, its just sleep(ms); with unistd.h, but how to do it in c++???
This is a discussion on making my program sleep / wait / delay... within the C++ Programming forums, part of the General Programming Boards category; Hi, basically, I am looking to put a pause into my program for about 1 second before doing a read. ...
Hi, basically, I am looking to put a pause into my program for about 1 second before doing a read. How can i do this??? i know is c, its just sleep(ms); with unistd.h, but how to do it in c++???
you can use Sleep(ms); with #include <windows.h>
edit:
Here is more info on it: http://faq.cprogramming.com/cgi-bin/...&id=1043284392
Operating Systems:
- Ubuntu 9.04
- XP
Compiler: gcc
> i know is c, its just sleep(ms); with unistd.h, but how to do it in c++???
This is an API issue, not a language issue.
The answer depends on the OS and compiler you're using more than the language.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I support http://www.ukip.org/ as the first necessary step to a free Europe.
OK! ...So, how can i ensure that my code will work on both unix/linux and windows based systems, if they both use different libraries???
is it something like
#IFDEF
Well the sleep function (which waits in units of a second) is a POSIX-1 function which nearly all 32-bit operating systems support.
It's in unistd.h on unix-like operating systems, but probably in something else on windows.
So you might need conditional compilation around a header file.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I support http://www.ukip.org/ as the first necessary step to a free Europe.