这是一个判别一个数组是不是数字的程序,有有关问题,请大家进来看看.
这是一个判别一个数组是不是数字的程序,有问题,请大家进来看看.
bool isnumber(char &a[]) ----------1
{
int i(0);
bool flat=1; //假定是数字
while(*(a+i)!= '\0 ')
{
if(*(a+i)> 0 && *(a+i) <9) ----------2
i++;
else
{
flat=0;
break;
}
}
return flat;
}
1:
error C2234: ' <Unknown> ' : arrays of references are illegal
2:
error C2446: ' < ' : no conversion from 'const int ' to 'char * '
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
error C2040: ' < ' : 'char * ' differs in levels of indirection from 'const int '
------解决方案--------------------
bool isnumber(char a[])
------解决方案--------------------
指针 to 引用非法的,数组同样
~-~
bool isnumber(char &a[]) ----------1
{
int i(0);
bool flat=1; //假定是数字
while(*(a+i)!= '\0 ')
{
if(*(a+i)> 0 && *(a+i) <9) ----------2
i++;
else
{
flat=0;
break;
}
}
return flat;
}
1:
error C2234: ' <Unknown> ' : arrays of references are illegal
2:
error C2446: ' < ' : no conversion from 'const int ' to 'char * '
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
error C2040: ' < ' : 'char * ' differs in levels of indirection from 'const int '
------解决方案--------------------
bool isnumber(char a[])
------解决方案--------------------
指针 to 引用非法的,数组同样
~-~