【问题标题】:C++ input compilation error [closed]C ++输入编译错误[关闭]
【发布时间】:2014-05-22 17:13:24
【问题描述】:

我试图在在线编译器 Ideone.com 上制作 C++ 输入文件。该程序旨在接收用户输入的英寸并将其转换为厘米。

    #include <iostream>
    using namespace std;

    int main() {
         int inches;
         float centimeters = 2.54;
         float convert;
         cout << "Input inches: ";
         cin >> inches;
         convert = inches * centimeters;
         cout << inches << "as centimeters is "<< convert;
return 0;
}

但是当我在网站上编译这个时,我无法输入任何东西,我得到这个作为输出

 Input inches: -1218641932as centimeters is -3.09535e+09

这是怎么发生的?有代码缺陷还是IDE?请帮忙。

【问题讨论】:

  • 这个问题似乎是题外话,因为它是关于如何使用在线编译器
  • 按“stdin”按钮并输入您的输入。
  • @Lightness Races in Orbit,那在哪里?我没有看到。
  • @Geto,编译器不允许我这样做
  • @Storm:你“没有看到”是什么意思?它就在您编写代码的框下方,在您选择语言的按钮旁边。仔细看。

标签: c++ input output


【解决方案1】:

您有一个文件可以输入您的输入,就在代码区域的下方;

输入输入(标准输入)

【讨论】:

  • 您需要在“ideone it”之前添加您的输入。当我在 Storm 代码的输入字段中输入 20 时,我得到以下结果: 输入英寸:20as cm is 50.8
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多