Linux+sublime Development of CIN/SCANF Solutions in C/D + +

Source: Internet
Author: User

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 + +

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.