Shutdown with timer

Hi, my program asks for an amount of seconds until the computer must shutdown.
This is what I have:
1
2
3
int n;
cin >> n;
system("shutdown -s -t n); 


I know this is not the correct syntax, but I would like to know how I can solve this? This works fine: system("shutdown -s -t 10");

Thanks in advance.
You can use stringstreams:
1
2
3
stringstream ss;
ss << "shutdown -s -t " << n;
system( ss.str().c_str() ); // str() returns a std::string with the contents of the stream, c_str() the equivalent C string 
My compilers gives an error at stringstream ss.
It says: aggregate 'std::stringstream ss' has incomplete type and cannot be defined

I deleted the second line 'using namespace std' and it still gives errors.
#include <sstream>
Why do You use the system()-command?...
Just making a small c++ project (just started with c++) called shutdown manager :)
I think system() is good because you can use cmd commands with it. Like system("cls"); to clear the screen.

It works fine now. Thanks!
Topic archived. No new replies allowed.