Q:sublime is configured in Ubuntu environment, can use GCC compiled to run the program, found that cin,scanf such a command does not execute
The A:sublime console does not support such an input operation, the solution is to call the Linux local terminal, execute the program on the terminal,
The online example of Windows down CMD has been much better, but seldom found the configuration method in the Linux environment,
The following is my own summary of the method, I feel very useful, I hope to help the needs of friends.
1.Sublime interface-->tools-->build system-->new Build System, pop up a simple file, paste the following code in,
The final result is as follows:
{ "cmd": ["g++ ${file}-o ${file_base_name}"], "File_regex":"^(.. [^:]*]:([0-9]+):? ([0-9]+)?:? (.*)$", "Working_dir":"${file_path}", "selector":"source.c, source.c++", "Shell":true, "variants": [ { "name":"Run", "cmd": ["${file_path}/${file_base_name}"] }, { "name":"Runinshell", "cmd": ["gnome-terminal-x bash-c ' ${file_path}/${file_base_name};read '"] } ]}
2. Save As G++.sublime-build, save location is the default path, that is, the Packages-->user directory
3. The third step, set the shortcut key, sublime interface-->preferences-->key bindings-user, open and write the following code, the results are as follows
[ "keys": ["F8""command " " Build ","args": {"variant"" Runinshell " } },]
Save.
4. This completes the call to the Linux terminal, sublime write a C + + program,
Ctrl+b compiles the program, CTRL+SHIFT+B runs the program using Sublime's own console, F8 to invoke Ubuntu terminal.
The point is that I have wasted some of my strength to test it out,
" cmd ": [""],
This code is called Gnome-terminal to execute the program, the following; Read must be added, or the program executes the terminal will flash back, plus after the execution of the program, hit enter to close the terminal.
Linux+sublime Development of CIN/SCANF Solutions in C/D + +