【发布时间】:2012-05-03 11:43:06
【问题描述】:
我从这里下载了 Code::Blocks:http://www.codeblocks.org/downloads/26
我正在学习 c 编程。当我运行以下程序时,出现错误:
iostream: No such file or directory
error: syntax error before "namespace"
warning: type defaults to `int' in declaration of `std'
warning: data definition has no type or storage class
In function `main':
error: `cout' undeclared (first use in this function)
error: (Each undeclared identifier is reported only once
error: for each function it appears in.)
error: `cin' undeclared (first use in this function)
我正在运行以下程序:
#include <iostream>
using namespace std;
int main()
{
int x;
x = 0;
do {
// "Hello, world!" is printed at least one time
// even though the condition is false
cout<<"Hello, world!\n";
} while ( x != 0 );
cin.get();
}
我尝试了 Dev-C++,我得到了同样的错误。 如何解决这个问题?
【问题讨论】:
-
如果你想学 C,那就快换学习材料吧,因为那是 C++
-
嗯,您显示的代码是 C++,而不是 C,所以我猜您正在尝试将它们编译为 C,这就是它失败的原因。