Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ usleep()

#include <iostream>
#include <unistd.h>     //required for usleep()
using namespace std;
int main(){
    //usleep will pause the program in micro-seconds (1000000 micro-seconds is 1 second)
    const int microToSeconds = 1000000;   
    const double delay1 = 2 * microToSeconds;     //2 seconds
    const double delay2 = 4.5 * microToSeconds;     //4.5 seconds
    
    cout<<"Delay 1 in progress... ("<<delay1/microToSeconds<<"s)"<<endl;
    usleep(delay1);        
    cout<<"  => Delay 1 is over"<<endl<<endl;
    
    cout<<"Delay 2 in progress... ("<<delay2/microToSeconds<<"s)"<<endl;
    usleep(delay2);
    cout<<"  => Delay 2 is over"<<endl<<endl;

    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: set platformio to C++17 
Cpp :: c++ messagebox 
Cpp :: clear file before writing c++ 
Cpp :: rng c++ 
Cpp :: como medir tiempo de ejecucion cpp 
Cpp :: colourful text in c++ 
Cpp :: 2114. Maximum Number of Words Found in Sentences leetcode solution in c++ 
Cpp :: fatal error: opencv2/opencv.hpp: No such file or directory 
Cpp :: c++ hello world program 
Cpp :: master header file c++ 
Cpp :: print array c++ 
Cpp :: uri online judge 1930 solution in c++ 
Cpp :: nth permutation c++ stl 
Cpp :: c++ converting centimeters to meters 
Cpp :: c++ save typeid 
Cpp :: expected number of trials to get n consecutive heads 
Cpp :: hi cpp 
Cpp :: rotate in cpp 
Cpp :: C compile SDL program using mingw 
Cpp :: qstring insert character 
Cpp :: qlabel set text color 
Cpp :: quotation in c++ string 
Cpp :: how to make crypto 
Cpp :: sfml mouse button pressed 
Cpp :: loop through char in string c++ 
Cpp :: sort function descending c++ 
Cpp :: C++ convert integer to digits, as vector 
Cpp :: c++ program to take input from user 
Cpp :: latex double subscript 
Cpp :: change to lowercase character c++ 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =