69,373
社区成员
发帖
与我相关
我的任务
分享
int main(void)
{
FILE *f1, *f2;
f1 = fopen("1.txt", "r");
f2 = fopen("2.txt", "w");
char buf[256];
char *p;
while (1)
{
if (NULL == fgets(buf, 255, f1)) break;
if (p = strstr(buf, "1234"))
{
memmove(p + strlen("5678"), p + strlen("1234"), strlen(p + strlen("1234")) + 1);
strncpy(p, "5678", strlen("5678"));
}
fprintf(f2, "%s", buf);
}
_fcloseall();
return 0;
}