c++一个小程序执行不了

howareyoussw 2009-11-14 04:46:44
麻烦各位大侠,让大家见笑了,这个简单的程序怎么也运行不了,提示错误
16 D:\c++\\104.cpp missing terminating " character
17 D:\c++\104.cpp expected primary-expression before "return"
17 D:\c++\\104.cpp expected `;' before "return"
我输入时也是用的英文半角呀


#include <iostream>

using namespace std;

class Human
{
public:
int wseight;
};


int main()
{
Human Tom;
Tom.wseight=85;
cout < <"汤姆的体重为" < <Tom.wseight < <"n\";
return 0;


}
...全文
164 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
howareyoussw 2009-11-16
  • 打赏
  • 举报
回复
十分谢谢17楼,我整了一天也没整明白,你一句,全解决了,能不能问你下您的QQ号呀,
wbgxx 2009-11-15
  • 打赏
  • 举报
回复
细心才是正道
liushuiyou_sheng 2009-11-15
  • 打赏
  • 举报
回复

黑体字是改动的
#include <iostream>
using namespace std;

class Human
{
public:
int wseight;
};


int main()
{
Human Tom;
Tom.wseight=85;
cout <<"汤姆的体重为" <<Tom.wseight <<"\n";
return 0;
}
fmxshj 2009-11-15
  • 打赏
  • 举报
回复
在主函数中return0;前加system("pause");它的意思是暂停,按任意键继续
howareyoussw 2009-11-15
  • 打赏
  • 举报
回复
谢谢大家的指教,根据大家的意见我改动后,不报错了,但是执行时,结果闪一上就没有了这是什么原因呀
lovesi3344 2009-11-14
  • 打赏
  • 举报
回复
说明了楼主没有学习C语言直接学习C++了
也可以
meizimeizi163 2009-11-14
  • 打赏
  • 举报
回复
要特别细心啊。
damo_xu 2009-11-14
  • 打赏
  • 举报
回复
楼主试试这个语句看看结果是什么:

cout<<"\" \"\n"<<endl;
MYLOVEwm 2009-11-14
  • 打赏
  • 举报
回复
哈哈,多了个分号
fmxshj 2009-11-14
  • 打赏
  • 举报
回复
n\改为\n;\n为转译符
kiwigiving 2009-11-14
  • 打赏
  • 举报
回复
\n 
\t
\r
……
kiwigiving 2009-11-14
  • 打赏
  • 举报
回复
转义字符 都是以  \  开头的
xxf012005 2009-11-14
  • 打赏
  • 举报
回复
n\
写反了……

mstlq 2009-11-14
  • 打赏
  • 举报
回复
注意\n

#include <iostream>

using namespace std;

class Human
{
public:
int wseight;
};


int main()
{
Human Tom;
Tom.wseight=85;
cout <<"汤姆的体重为" <<Tom.wseight <<"\n";
return 0;
}
yzx714 2009-11-14
  • 打赏
  • 举报
回复
\n才是转义字符
老邓 2009-11-14
  • 打赏
  • 举报
回复
最后你是打错了?

或者:

#include <iostream>

using namespace std;

class Human
{
public:
int wseight;
};

int main()
{
Human Tom;
Tom.wseight = 85;
cout << "汤姆的体重为" << Tom.wseight << "\n";
return 0;
}

cout << "汤姆的体重为" << Tom.wseight << "\n";
jackyjkchen 2009-11-14
  • 打赏
  • 举报
回复
n\
写反了……
老邓 2009-11-14
  • 打赏
  • 举报
回复
#include <iostream>

using namespace std;

class Human
{
public:
int wseight;
};

int main()
{
Human Tom;
Tom.wseight = 85;
cout << "汤姆的体重为" << Tom.wseight << "n\"";
return 0;
}


Tom.wseight << "n\"";

64,648

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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