How can I replace ifstream infile("jobs.txt"); with argv[1] command line?
This is my main function :
int main() { int arrSize=0; vector<Process> procs; vector<Process> proc; int element1, element2, element3; char comma; ifstream infile("jobs.txt"); if (!infile.is_open()) { cerr << "Can't open file" << endl; } else { while (infile >> element1 >> comma >> element2 >> comma >> element3) { Process proc{element1, element2, element3}; procs.push_back(proc); } } arrSize=procs.size(); cout << procs.size() << endl; int n = sizeof(proc) / sizeof(proc[0]); findavgTime(procs.data(), static_cast<int>(procs.size())); } https://stackoverflow.com/questions/67223606/open-text-file-with-argument-argv1-command-line April 23, 2021 at 11:29AM
没有评论:
发表评论