#include
#include
#include
void sort(char *p, char *q)
{
int i, j, len;
if ( (p[0]=='+')&&(p[1]=='8')&&(p[2]=='6') )
strcpy(q, p+3); //去掉“+86”
else if ( (p[0]=='+')&&(p[1]=='8')&&(p[2]=='8')&&(p[3]=='6') )
strcpy(q, p+4); //去掉“+886”
else
strcpy(q, p);
for (i=0; i
{
if (q[i]=='-') //去掉其中的"-"
{
for (j=i; j
q[j] = q[j+1];
}
}
}
void main(void)
{
unsigned long no[500]; //默认不超过500条数据
FILE *fp;
char str1[20], str2[20];
int i = 0;
fp = fopen("phone.txt", "r");
if (NULL == fp) return; //打开文件失败
while (!feof(fp))
{
fgets(str1, 20, fp); //从文件中读一行数据,默认一行不会超过20个字符
sort(str1, str2);
no[i] = atol(str2); //将字符串转化为长整型
i++;
}
fclose(fp);
}
取消
评论