主题:[讨论]一个C++源码
#include"iostream.h"
#include"string"
int main()
{
int nNumber;
cout<<"输入一个阿拉伯数字:";
cin>>nNumber;
char str[]={"零"};
switch(nNumber)
{
case 0:
{
strcpy(str,"零");
break;
}
case 1:
{
strcpy(str,"一");
break;
}
case 2:
{
strcpy(str,"二");
break;
}
case 3:
{
strcpy(str,"三");
break;
}
case 4:
{
strcpy(str,"四");
break;
}
case 5:
{
strcpy(str,"五");
break;
}
case 6:
{
strcpy(str,"六");
break;
}
case 7:
{
strcpy(str,"七");
break;
}
case 8:
{
strcpy(str,"八");
break;
}
case 9:
{
strcpy(str,"九");
break;
}
default:
{
cout<<"输入错误 ! ";
return 0 ;
}
}
cout<<nNumber<<" 对应的大写汉字是 "<<str"<<\n";
}
Compiling...
1.cpp
f:\study\vc作业\输入阿拉伯数字,输出汉字\1.cpp(69) : error C2143: syntax error : missing ';' before 'string'
执行 cl.exe 时出错.
1.exe - 1 error(s), 0 warning(s)
我找不到在什么地方漏分号,谁能够指教一下
#include"string"
int main()
{
int nNumber;
cout<<"输入一个阿拉伯数字:";
cin>>nNumber;
char str[]={"零"};
switch(nNumber)
{
case 0:
{
strcpy(str,"零");
break;
}
case 1:
{
strcpy(str,"一");
break;
}
case 2:
{
strcpy(str,"二");
break;
}
case 3:
{
strcpy(str,"三");
break;
}
case 4:
{
strcpy(str,"四");
break;
}
case 5:
{
strcpy(str,"五");
break;
}
case 6:
{
strcpy(str,"六");
break;
}
case 7:
{
strcpy(str,"七");
break;
}
case 8:
{
strcpy(str,"八");
break;
}
case 9:
{
strcpy(str,"九");
break;
}
default:
{
cout<<"输入错误 ! ";
return 0 ;
}
}
cout<<nNumber<<" 对应的大写汉字是 "<<str"<<\n";
}
Compiling...
1.cpp
f:\study\vc作业\输入阿拉伯数字,输出汉字\1.cpp(69) : error C2143: syntax error : missing ';' before 'string'
执行 cl.exe 时出错.
1.exe - 1 error(s), 0 warning(s)
我找不到在什么地方漏分号,谁能够指教一下