~riderius/cpp-code

cpp-code/codetime.cpp -rw-r--r-- 622 bytes
380d65aariderius digits_analysis.cpp: argv[1] can replace n 9 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <string>

void execute(const char* path)
{
    std::system(path);
}

int main(int argc, char* argv[])
{
    using namespace std;
    string path;
    if (argc == 1)
        getline(cin, path);
    else if (argc == 2)
        path = argv[1];
    else {
        path = argv[1];
        for (int i = 2; i < argc; i++) {
            path += " ";
            path += argv[i];
        }
    }

    unsigned int start = clock();
    execute(path.c_str());
    unsigned int end = clock();
    cout << "Time for executable: " << end - start << endl;
    return 0;
}