#Why is my system function not working in executable file?

11 messages · Page 1 of 1 (latest)

sturdy cape
#

Very basic program, code shown above/below. It only works when I debug it from Visual Studio, doesn't work when I open the exe separatly.

atomic talonBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

outer carbon
#

For starters, show your entire code (as text, not a screenshot)

atomic talonBOT
#
HolyBlackCat
Please Do Not Send Screenshots or Photos!

They're hard to read and prevent copying and pasting.

sturdy cape
#

#include <iostream>
#include <stdlib.h>
#include <windows.h>
#include <string>

using namespace std;

int main()
{
int a;
printf("Shuwdown time in (mins):");
cin >> a;
a = a * 60;
auto b = to_string(a);
system(("shutdown -s -t " + b).c_str());
}

dapper cliffBOT
#

Hello! I can compile code for you. To compile code, use the ;compile command. type ;help compile for more information.

If you are unfamiliar with Markdown, codeblocks can be created by formatting your message as the following.
```
<code>
```

atomic talonBOT
#
How to Format Code on Discord
Markup

```cpp
int main() {}
```

Result
int main() {}
sturdy cape
#
#include <iostream>
#include <stdlib.h>
#include <windows.h>
#include <string>

using namespace std;

int main()
{
    int a;
    printf("Shuwdown time in (mins):");
    cin >> a;
    a = a * 60;
    auto b = to_string(a);
    system(("shutdown -s -t " + b).c_str());
}
ionic crest
#

Did you run as admin?

sturdy cape
ionic crest