RoyalGao

要像一棵树栽在溪水旁,按时侯结果子,叶子也不枯干(诗篇)。
Mail: gaoquanning@163.com

导航

读写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 != '\0')
{
if ((*p) <'0' && (*p) > '9')
{
isDigit = false;
break;
}
p++;
}
if (isDigit == true)
fprintf(wfp, buf);
else
continue;
fprintf(wfp, "\n");
}
fclose(fp);
fclose(wfp);
return 0;
}


posted on 2013-08-19 11:34  RoyalGao  阅读(268)  评论(0编辑  收藏  举报