读写txt

读写txt

abc1223@126.com
11222
aadad222@qq.com
1243444
vvv4444@qq.com
5444444
把邮箱的数字排除掉

#include <stdio.h>
#include <stdlib.h>

int main()
{
FILE * fp = fopen("in.txt", "rb");
if (fp == NULL)
{
fprintf(stderr, "cannot open file");
exit(0);
}

FILE * wfp = fopen("out.txt", "w");
if (wfp == NULL)
{
fprintf(stderr, "cannot open file");
exit(0);
}

char buf[1024];
char * p;
bool isDigit = true;
while (fgets(buf, 1024, fp))
{
isDigit = true;
p = buf;
while (p != '')
{
if ((*p) <'0' && (*p) > '9')
{
isDigit = false;
break;
}
p++;
}
if (isDigit == true)
fprintf(wfp, buf);
else
continue;
fprintf(wfp, " ");
}
fclose(fp);
fclose(wfp);
return 0;
}



Best Regards To Reader:
==============================================
Royal Kao(高全宁)
Mob: 13771921045
Mail: gaoquanning@163.com
Blog: http://www.cnblogs.com/gaoquanning/
==============================================
原文地址:https://www.cnblogs.com/gaoquanning/p/3267496.html