The article How to use VSCode software to run C code has already introduced how to run C code in VSCode software, but recently when using scanf to input from the keyboard, "Code is already running!" is displayed after running the code, as shown in the figure below. The output window cannot be entered via keyboard.
The solution is as follows:
first open the settings, click the settings icon in the lower left corner, then click Settings, a window as shown below will pop up, enter RunInTerminal in the search box and check Whether to run code in Integrated Terminal. If you do this, the result after running will
be Display in the terminal window, not the output window.
The scanf input problem cannot be solved only through the above operations, and the launch.json file needs to be modified, but I don’t know if it is a version problem or some reason, there is no such file.
I saw a post saying that the installed C/C++ plug-in may be too new. Click the C/C++ plug-in gear in the figure below, choose to install another version, and find the installation of version 1.8.4, as shown in the figure below.
VScode (C/C++) cannot automatically generate the launch.json file. Solution The article mentions that the launch.json file can be generated after changing the plug-in version, but it is still not generated after I operate, but it does solve the scanf input problem. The specific input effect is shown in the figure below.
The problem of garbled Chinese characters is shown in the figure below.
Click UTF-8 in the lower right corner and choose to reopen with encoding, as shown in the figure below.
Select Simplified Chinese(GB2312).
At this time, the Chinese character comments in the code will also be garbled, as shown in the figure below.
Press Ctrl+Z to restore Chinese. Save the code and run it. Then the code will not be garbled. The result is as shown in the figure below.
Moreover, the encoding format in the lower right corner has also changed from the original UTF-8 to GB 2312.
The above is how VSCode solves the input problem of scanf. For some settings, you can refer to the following article!
Reference article:
How vscode runs c language, scanf input
VScode (C/C++) cannot automatically generate the launch.json file solution
How does VSCode solve the input problem of scanf - Code is already running!
Guess you like
Origin blog.csdn.net/weixin_42570192/article/details/132480317
Ranking