I'm new to c, so I'm probably stupid.
Here is somewhat my code:
#include <stdio.h>
#include <stdlib.h>
int main() {
int input;
setvbuf(stdout, NULL, _IONBF, 0);
printf("Welcome to example");
printf("\n" "Select an option." "\n" "1. ex1" "\n" "2. ex2" "\n");
scanf("%d", &input);
if (input == 1) {
printf ("You selected ex1.");
system("echo 'testing.'");
}
else if (input == 2) {
printf ("You selected ex2.");
}
return 0;
}
If you're wondering, I'm running the exe in MSYS2 with ./a.exe
If I input 1, then it should execute the command echo. However, it does nothing.
How do I fix this?
Edit: Heres the output
You selected ex1.
And then the program ends. It could be because system uses command prompt (I'm having issues with command prompt...), so how do I switch it to use MSYS2 as the system terminal?