| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 500 人关注过本帖
标题:[求助]定义的错误吗?
只看楼主 加入收藏
灼光
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2006-5-12
收藏
 问题点数:0 回复次数:7 
[求助]定义的错误吗?
下面的程序总是出现这样的错误,
请帮我看一下,谢谢!!
.cpp(12) : error C2061: syntax error : identifier 'k'
*******************
*******************
#include "iostream.h"
void main()
{
char k;
char a='y';
char b='n';
cout<<"现在下雨吗?"<<endl;
cin>>k;
do
{if (k==a)
cout<<"现在正在下雨"<<endl;
if(k==b) cout<<"现在不下雨"<<endl;}
while((k!=a)&&(k!=b));
cout<<"error!";
}
搜索更多相关主题的帖子: 定义 
2006-10-12 15:46
Bekky
Rank: 3Rank: 3
等 级:新手上路
威 望:7
帖 子:354
专家分:0
注 册:2006-5-29
收藏
得分:0 
代码好像没错啊,那你把k换一成一个厂一点的看看,是不是和系统的关键字冲突了??

我的编译环境为WinXp + VC 6.0 http://blog..cn/yobo
2006-10-12 16:00
w5941120
Rank: 1
等 级:新手上路
帖 子:53
专家分:0
注 册:2006-4-16
收藏
得分:0 

你是字符在比较,该用strcmp函数

想了想,又不是这个原因,我讲错了,SORRY!

[此贴子已经被作者于2006-10-12 17:22:41编辑过]

2006-10-12 17:16
flypampas
Rank: 1
等 级:新手上路
帖 子:28
专家分:0
注 册:2006-9-16
收藏
得分:0 
    VC6.0编译没有错啊!

java,c++...thinking......
2006-10-12 20:10
踏魔狼
Rank: 6Rank: 6
等 级:贵宾
威 望:24
帖 子:1322
专家分:33
注 册:2005-9-22
收藏
得分:0 
对呀!

=×&D o I p R e E n C g T l X&×=
2006-10-12 20:36
wfpb
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:2188
专家分:0
注 册:2006-4-2
收藏
得分:0 
以后有错误,可以去MSDN上查,我最近都是在那查的。很管用的。呵呵

Compiler Error C2061
syntax error : identifier 'identifier'

The compiler found identifier where it was not expected. This error can be caused by enclosing an initializer in parentheses. The error can be avoided by enclosing the declarator in parentheses or making it a typedef. The following example causes this error and shows two fixes:

class X {};
class Y {};
class Z {};
class W : public X, public Y, public Z {};

void func ( W* pW )
{
X* pX ( pW ); // Error: unexpected identifier 'pW'

Y ( *pY ) ( pW ); // OK, declarator in parentheses

typedef Z *pZ_t;
pZ_t pZ ( pW ); // OK, typedef used for Z
}


[glow=255,red,2]wfpb的部落格[/glow] 学习成为生活的重要组成部分!
2006-10-12 22:18
灼光
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2006-5-12
收藏
得分:0 
谢谢了!
英语理解有困难呀.
但是有同学帮忙呢.

2006-10-13 13:58
lzy340623339
Rank: 1
等 级:新手上路
帖 子:37
专家分:0
注 册:2006-10-12
收藏
得分:0 
语法上是没错,可你理解错了do...while语句的用法,所以即使运行得了,结果也不是年所想的
2006-10-16 14:07
快速回复:[求助]定义的错误吗?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015281 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved