I have such a question. So I wrote a console application on C. In codeblocks, it works as it should, i.e. I / O. But when an application is opened through the executable (* .exe) in the program folder, only input is realized, and then the program just crashes.

Here is the code:

#include <stdio.h> #include <stdlib.h> int main() { int a, b, c, m; printf("Input values for comparsion: \n"); scanf("%d %d %d", &a, &b, &c); m = a; if (b < m) { m = b; } if (c < m) { m = c; } printf("Minimum is: %d\n", m); return 0; } 

Banal application to just deal with this problem. I tried to insert getch() both after scanf and before return .

Zero effect. Tell me, please, what's the problem?

  • one
    "... and then the program just crashes" - what does this mean? "But when the application is opened through the executable ..." - what is meant by this? This is a console application, as you yourself called it. It must be run from the console. Are you running from the console? - AnT
  • Yes, even through the console in vs code crashes. here, let's say, I start debugging in vs code, enter the data, press enter, and the program crashes - Prometheus Music
  • Everything works there, most likely you just type in the wrong format. Separate numbers with spaces, not commas. - freim
  • I'm doing this :) I have a little more brain left :) - Prometheus Music
  • Flying Out is not a description of the problem. You should obviously get acquainted with the debugger. If the program normally reaches return 0 , then nothing flies, and if not, then you should write on what specific line what happens. - VTT

1 answer 1

Import conio.h and add getchar () to the end.