这段代码想检测输入是否为正整数,但输入是整数的时候不能得到结果,函数不返回1
#include <stdio.h>
#include <string.h>
int isint(char x[]){
int mark=0; // used for loop marking
int i;
while (mark==0){
for (i=0; i<strlen(x); i++){ // check if it is a int
if (x[i]>='0' && x[i]<='9'){
continue;
}else{
return mark;
}
}
}
mark=1;
return mark;
}
int main ()
{
char table[100];
int i=0;
while((table[i] = getchar()) != '\n') i++;
table[i] = '\0';
int a=isint(table);
printf("%d", a);
return 0;
}