I want use clock
function in my program so I am referring to how to use clock().
My code :
#include <iostream>
#include <cstdio>
#include <ctime>
int main() {
std::clock_t start;
//clock_t start;
double duration;
start = std::clock();
//start = clock(); //This Also not working
/* Your algorithm here */
duration = ( std::clock() - start ) / (double) CLOCKS_PER_SEC;
//duration = ( clock() - start ) / (double) CLOCKS_PER_SEC;
std::cout<<"printf: "<< duration <<'\n';
}
But still I am having compilation errors
error C2039: 'clock' : is not a member of '`global namespace'' ....\ctime
error C2873: 'clock' : symbol cannot be used in a using-declaration ....\ctime
error C3861: 'clock': identifier not found ....\main.cpp
So I have checked ctime
header file by opening in visual studio in that also
using _CSTD asctime; using _CSTD clock; using _CSTD ctime;
for this line it's gives an error
Error: the global scope has no "clock"
Please help me to solve these errors?