我通常是一名Java程序员,几乎完全使用textmate,但最近我开始使用C++。但是当我使用甚至最基本的程序并纳入关键字,并运行程序,我没有得到一个oppurtunity在运行时放入任何东西,有时它本身插入随机值!例如,如果我跑这在TextMate中:在textmate中使用cin和cout
#include <iostream>
int stonetolb(int);
int main() {
using namespace std;
int stone;
cout << "enter the weight in stone";
cin >> stone;
int pounds = stonetolb(stone);
cout << stone << "stone = ";
cout << pounds <<" pounds.";
return 0;
}
int stonetolb(int sts) {
return 14 * sts;
}
就出来与输出:
在stone32767stone = 458738磅输入重量。
为什么会发生这种情况,我该如何阻止它?
Ehm用户错误...你错过了新的行吗?我相信该程序正在完美地执行您的指示。究竟哪部分输出是随机的? – 2011-11-20 16:14:52
我没有输入任何值,它插入了32767,我可以放入任何想要的值 –