+ 3
Shut down PC via C++
Hello guys! I need a small help. I want to turn off my pc after some time but i want a program that accepts an input and then pass it to the function "system". I know if i put seconds (f.e 3600 ) and not use the variable "tim" that the program will work. Is there any way to do so? here is my code: https://code.sololearn.com/c66dBstGgjoE/#cpp thanks anyway :D
5 Respostas
+ 2
you arent using the variable, you are using the string "tim"
+ 2
have you converted value of tim to string? read about std::to_string function.
and then do like:
system("first part" + tim_string + "second part");
I think it should work.
+ 1
You have a point! I tried it But it didn't work... Or I did something wrong... :/
+ 1
Thank you guys very much. I am sorry about the days that gone without answering. I used "kurwius" answer and now the exe works fine!! I am able to shut down my pc right at the time(minutes) that I want to! Be well!