I have the following code sample:
#include
#include
#include
using namespace std;
void main()
{
SHELLEXEC
I tried your code on Windows 10, and SysInternals Process Monitor shows the following:
As you can see, calc.exe
spawns a new process and then ends, thus satisfying the wait. That is why you see your output immediately. This second process is the actual calculator process. In my case, it is located at this path:
C:\Program Files\WindowsApps\Microsoft.WindowsCalculator_10.1612.3341.0_x64__8wekyb3d8bbwe\Calculator.exe