Inserting Numbers into a command

Posts 1–8 of 8 · Page 1 of 1
Inserting Numbers into a command
Code:
cout << "Shutdown:\n";
//cin >> seconds;
system("shutdown -s -f -t"); //I want to place the seconds right after -t
How would I input seconds into my system command?
Well you could do
[Highlight=cpp]

int iSeconds;
cin >> iSeconds;

Sleep(iSeconds*1000); //1000 Millisecond = 1 Second
system("shutdown");

[/Highlight]

Should work, Test for me
Thanks, but now how would I do it for this type of problem?

Code:
system("cls");
cout << "Run:\n";
string item;
cin >> item;
//OpenProcess()//This will be whatever they typed in item
I want them to type the program they want to open. It will store it inside of item, then it will use it in OpenProcess
Quote Originally Posted by aanthonyz View Post
Thanks, but now how would I do it for this type of problem?

Code:
system("cls");
cout << "Run:\n";
string item;
cin >> item;
//OpenProcess()//This will be whatever they typed in item
I want them to type the program they want to open. It will store it inside of item, then it will use it in OpenProcess
I think you want to save what they type in then open up later?

In that case, make it like:

Code:
char *xxxxx;

void "w/e function is"(void){
char *xxxxx = (w/e they typed in here);

OpenProcess(xxxxx);
}
char shut[100];
int iTime = 6000;
wsprintf(shut,"shutdown -s -f -t %d",iTime);
system(shut);

for the first problem... second problem i dont really get what u mean... (if its what i guess u can use the solution i gave u also for this)
Thank you, but can anyone help with my other problem
It just sounds weird.
Posts 1–8 of 8 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Need help?