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

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

概述如何在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: 如何在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#endifint 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;}
总结

以上是内存溢出为你收集整理的Sublime Text,带有c程序的控制台输入全部内容,希望文章能够帮你解决Sublime Text,带有c程序的控制台输入所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1107840.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-29
下一篇2022-05-29

发表评论

登录后才能评论

评论列表(0条)

    保存