Sublime Text,带有c程序的控制台输入

如何在SublimeText 2.0.1中使用控制台输入?
我选择了“工具 – >构建系统 – > C”,并将hello.cpp文件添加到项目中:
#include <iostream>
int main() 
{
    int a,b,c;
    std::cout << "Enter: ";
    std::cin >> a >> b;
    c = a + b;
    std::cout << a << '+' << b << '=' << c << std::endl;
    return 0;
}

建立成功,但当我运行(“工具 – >运行”)时,行“std :: cin>> a>> b;”传递,我无法输入值.
在终端与g运行良好.
操作系统:Ubuntu 12.04

解决方法

我不认为Sublime Text支持stdin,但是,你可以创建一个文件stdin.input并在编辑器下使用它:
#include <iostream>
#include <fstream>

#define SUBLIME

#if defined SUBLIME
#  define ISTREAM ifile
#else
#  define ISTREAM std::cin
#endif

int main() 
{
    int a,c;
    std::cout << "Enter: ";
    #if defined (SUBLIME)
      std::ifstream ifile("stdin.input");
    #endif
    ISTREAM >> a >> b;
    c = a + b;
    std::cout << a << '+' << b << '=' << c << std::endl;
    return 0;
}

相关文章

vue阻止冒泡事件 阻止点击事件的执行 &lt;div @click=&a...
尝试过使用网友说的API接口获取 找到的都是失效了 暂时就使用...
后台我拿的数据是这样的格式: [ {id:1 , parentId: 0, name:...
JAVA下载文件防重复点击,防止多次下载请求,Cookie方式快速简...
Mip是什么意思以及作用有哪些