Search
 
SCRIPT & CODE EXAMPLE
 

CPP

How do I read computer current time in c++

#include <iostream>
#include <chrono>
#include <ctime>    

int main()
{
    auto start = std::chrono::system_clock::now();
    // Some computation here
    auto end = std::chrono::system_clock::now();

    std::chrono::duration<double> elapsed_seconds = end-start;
    std::time_t end_time = std::chrono::system_clock::to_time_t(end);

    std::cout << "finished computation at " << std::ctime(&end_time)
              << "elapsed time: " << elapsed_seconds.count() << "s
";
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: gcc suppress warning inline 
Cpp :: c++ lettura file 
Cpp :: vector c++ 
Cpp :: Visual studio code include path not working c++ 
Cpp :: joining two vectors in c++ 
Cpp :: comparing characters of a string in c++ 
Cpp :: how to generate number in c++ 
Cpp :: cpp auto 
Cpp :: vector iterating in c++ 
Cpp :: c++ class template 
Cpp :: map in cpp 
Cpp :: how to make a square root function in c++ without stl 
Cpp :: how to add space in c++ 
Cpp :: lambda function in c++ 
Cpp :: c++ data types 
Cpp :: how to sort array in c++ 
Cpp :: find positive number factorial in C++ 
Cpp :: loop c++ 
Cpp :: sweetalert2 email and password 
Cpp :: hierarchical inheritance in c++ employee 
Cpp :: flutter single instance app 
Cpp :: c++ garbage collection 
Cpp :: lists occurrences of characters in the string c++ 
Cpp :: cpp malloc 
Cpp :: unordered_map c++ 
Cpp :: how to use power in c++ 
Cpp :: c++ function pointer as variable 
Cpp :: c++ check first character of string 
Cpp :: malloc 2d array cpp 
Cpp :: auto in cpp 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =