C language study notes use vscode external console to crash -12

foreword

When using the external console of vscode, there will be a flashback phenomenon. This is because the system automatically exits the terminal after the program finishes running (determined by the terminal mechanism). After the C program ends, we can use the system function to suspend the DOS terminal system, so that we can completely see the running process of the program.

Solution 1

Add the stdlib.h header file above the program, and then call the system function to suspend the system function after the program ends.
insert image description here

Effect:
insert image description here

Solution 2

Open the lauch.json file, modify the two parameters Program and args, the relevant configuration is as follows:
"program": "C:\Windows\System32\cmd.exe",
"args": ["/c", " file D irname / {fileDirname}/fileDirname/{fileBasenameNoExtension}.exe”,“&”,“pause”],
insert image description here

Effect:
insert image description here

Summarize

Both methods are possible. If you want to do it once and for all, it is recommended to choose the second method. Well, see you in the next chapter, come on!

Guess you like

Origin blog.csdn.net/weixin_37171673/article/details/132162853