【返回】 判断的结果,类型为int
C代码如下:
#include<stdio.h> #include<stdlib.h> #include<string.h> #define LEN 13 #define SIZE 100 int verifyMsisdn(char* inMsisdn); int main() { char *str = (char*)malloc(SIZE*sizeof(char)); printf("please input the cellphone number:"); scanf("%s",str); printf("the result is %d\n",verifyMsisdn(str)); return 0; } int verifyMsisdn(char* inMsisdn) { int flag = 0; if(LEN == strlen(inMsisdn)) { if(*inMsisdn == '8' && *(inMsisdn+1) == '6') flag = 1; while(*inMsisdn != '\0') { if(*inMsisdn >= '0' && *inMsisdn <= '9') inMsisdn++; else return 2; } if(flag == 1) return 0; else return 3; } else return 1; }
原文:http://blog.csdn.net/hs794502825/article/details/37992241