Hey guys, noob at linux here
I have some c++ code that i wanna run through linux
My program accepts two command line arguments: an iteration count and a “sleep” time.
this is my code
Code:
//test.cpp
#include <iostream>
#include <time.h>
#include <stdio.h>
#include <cstdlib>
using namespace std;
void wait (int seconds)
{
clock_t endwait;
endwait = clock () + seconds * CLOCKS_PER_SEC ;
while (clock() < endwait) {}
}
int main(int argc, char* argv[])
{
time_t MainTime;
struct tm* InfoTime;
int SleepNum, Times;
int InputSpace[2];
int i;
for(i = 1; i < argc; i++)
InputSpace[i-1] = atoi(argv[i]);
time(&MainTime);
InfoTime = localtime(&MainTime);
printf("Program started on %s\n", asctime(InfoTime));
for(i = 1; i<=InputSpace[0]; i++)
{
cout << "\nRun Number " << i;
cout << "\nWill Sleep for " << InputSpace[1] <<" seconds\n";
wait(InputSpace[i-1]);
}
time(&MainTime);
InfoTime = localtime(&MainTime);
printf("\nProgram ended on %s\n", asctime(InfoTime));
}
i gotta put in my command line something like: "text.exe 7 2(enter)"
my question is how do i run this program in the command line while putting these numbers at the end? (if i need to change any part of my code please let me know). do i need to go into the shell? how do i run it in the shell?
another question is how do i take what i see in the shell and copy it to a text file?
with that done i need to Find out the process ID of test.cpp, Find out all running processes that are related to the name test, While test is still running in one shell issue a command on the other shell that terminates it. and thats it.
Thanx!