re:错哪里了?

pvii 2003-01-16 11:54:01
在vc++里编译如下程序
#include <iostream>
// #include <iostream>

/**
**
the while loop has executed 1 times
the while loop has executed 2 times
the while loop has executed 3 times
the while loop has executed 4 times
the while loop has executed 5 times
**
**/
int main()
{
int iterations = 0;
bool continue_loop = true;

while ( continue_loop != false )
{
iterations++;

cout << "the while loop has executed "
<< iterations << " times\n";

if ( iterations == 5 )
continue_loop = false;
}

return 0;
}

c:\program files\microsoft visual studio\vc98\include\eh.h(32) : fatal error C1189: #error : "eh.h is only for C++!"
谢谢
...全文
44 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
pvii 2003-01-16
  • 打赏
  • 举报
回复
谢谢解决了。
这段程序时C++ Primer里的源码,我下载的全是以c后缀。
liu_feng_fly 2003-01-16
  • 打赏
  • 举报
回复
你的程序文件后缀是.c吗?改成.cpp试试,编译器可能认为你的程序是c程序,不是c++的
birth_chen 2003-01-16
  • 打赏
  • 举报
回复
#include <iostream>
// #include <iostream>

/**
**
the while loop has executed 1 times
the while loop has executed 2 times
the while loop has executed 3 times
the while loop has executed 4 times
the while loop has executed 5 times
**
**/
int main()
{
using namespace std; //加上这一句
int iterations = 0;
bool continue_loop = true;

while ( continue_loop != false )
{
iterations++;

cout << "the while loop has executed "
<< iterations << " times\n";

if ( iterations == 5 )
continue_loop = false;
}

return 0;
}
刚才试了没问题
pvii 2003-01-16
  • 打赏
  • 举报
回复
没用还是同样
web_spider 2003-01-16
  • 打赏
  • 举报
回复
using namespace std;

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧