标题:请教文件里指定字符替换问题
取消只看楼主
heizhizhu007
Rank: 2
等 级:论坛游民
帖 子:50
专家分:10
注 册:2016-2-19
结帖率:92.31%
已结贴  问题点数:10 回复次数:1 
请教文件里指定字符替换问题
if(strcmp(data,"this")==0)   《--这里的  0是 什么意思?
fseek(fp,-(long)strlen("this"),SEEK_CUR)《-- 这里的  long是什么意思?

#include<stdio.h>
#include<string.h>

int main()
{
    FILE *fp=fopen("a.txt","r+");
    char data[100];

    if(fp==NULL)
    {
        printf("no data \n");
        return 0;
    }

    while((fscanf(fp,"%s",data))!=EOF)
    {
        if(strcmp(data,"this")==0)
        {
            fseek(fp,-(long)strlen("this"),SEEK_CUR);
            fputs("that",fp);

            fflush(fp);

        }
    }

    fclose(fp);

}
2016-03-26 10:59
heizhizhu007
Rank: 2
等 级:论坛游民
帖 子:50
专家分:10
注 册:2016-2-19
得分:0 
2016-03-26 11:45



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-462950-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.113541 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved