帮忙看看这个C++程序哪里错了
#include<iostream.h>voidxinghao();voidmain(){chara[10]=1230000000000,b[10]=0000000000...
#include<iostream.h>
void xinghao();
void main()
{
char a[10]=1230000000000,b[10]=0000000000;
cout<<"欢迎进入Mr.five的乐园"<<endl;
while(a!=b)
{
cout<<"请输入密码:";
cin>>b;
if(a==b)cout<<"密码正确";
else cout<<"密码错误";
}
}
--------------------Configuration: mima - Win32 Debug--------------------
Compiling...
mima.cpp
D:\Program Files\Microsoft Visual Studio\MyProjects\mima\mima.cpp(5) : error C2440: 'initializing' : cannot convert from 'const __int64' to 'char [10]'
There are no conversions to array types, although there are conversions to references or pointers to arrays
D:\Program Files\Microsoft Visual Studio\MyProjects\mima\mima.cpp(5) : error C2440: 'initializing' : cannot convert from 'const int' to 'char [10]'
There are no conversions to array types, although there are conversions to references or pointers to arrays
Error executing cl.exe.
mima.exe - 2 error(s), 0 warning(s) 展开
void xinghao();
void main()
{
char a[10]=1230000000000,b[10]=0000000000;
cout<<"欢迎进入Mr.five的乐园"<<endl;
while(a!=b)
{
cout<<"请输入密码:";
cin>>b;
if(a==b)cout<<"密码正确";
else cout<<"密码错误";
}
}
--------------------Configuration: mima - Win32 Debug--------------------
Compiling...
mima.cpp
D:\Program Files\Microsoft Visual Studio\MyProjects\mima\mima.cpp(5) : error C2440: 'initializing' : cannot convert from 'const __int64' to 'char [10]'
There are no conversions to array types, although there are conversions to references or pointers to arrays
D:\Program Files\Microsoft Visual Studio\MyProjects\mima\mima.cpp(5) : error C2440: 'initializing' : cannot convert from 'const int' to 'char [10]'
There are no conversions to array types, although there are conversions to references or pointers to arrays
Error executing cl.exe.
mima.exe - 2 error(s), 0 warning(s) 展开
展开全部
1. 初始化字符数组应当加引号
字串山如长度不大于数组长度减一;最后一拿扒位置留给字串结束标志\0
char a[10]="123000000",b[10]="000000000";
2. 字串值的逗敏启比较要一个一个的比,
if(a==b) 是恒假判断,比较的是数组地址
应改为:
int la=strlen(a);
while(1){
cout<<"请 输入密码:";
cin>>b;
int i;
if((i=strlen(b))!=la)continue;
i--;
while((i+1)&&(a[i]==b[i]))i--;
if(i==-1){
cout<<"RIGHT";break;
}else{
cout<<"WRONG";
}
}
字串山如长度不大于数组长度减一;最后一拿扒位置留给字串结束标志\0
char a[10]="123000000",b[10]="000000000";
2. 字串值的逗敏启比较要一个一个的比,
if(a==b) 是恒假判断,比较的是数组地址
应改为:
int la=strlen(a);
while(1){
cout<<"请 输入密码:";
cin>>b;
int i;
if((i=strlen(b))!=la)continue;
i--;
while((i+1)&&(a[i]==b[i]))i--;
if(i==-1){
cout<<"RIGHT";break;
}else{
cout<<"WRONG";
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询