我正在使用 isalpha() 来确定行上是否有字符,它显示行“90 1 0”包含字母字符。
这是相关代码
bool digitTest(char *test, int arysize)
{
int i;
for (i =0; i<arysize; i++)
{
if ((isalpha(test[i])) != 0){
return 0;
}
if (i==arysize)
return 1;
i++;
}
return 1;
}
这里被称为
char buffer[4096] = {};
while(NULL!=fgets(buffer, sizeof(buffer), fp)){
if (digitTest(buffer, 4096) == 0){
printf ("contains alpha\n");
continue;
/*printing code if there is no alphabetic characters below, i do not believe it is relevant*/
这是输出
1
1
1
contains alpha
contains alpha
contains alpha
25123.90
54321.23
6
并输入
1
1
1
89 23.5 not a number
90 1 0
-5.25 not a number 10000
25123.90 54321.23 6