打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
fread小函数
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    char buff[128];

    char *match;
    FILE* fd;
    int rdbyt;

    fd=fopen("F:/Downloads/test.txt","r");
    if(fd<0) {
        printf("open file error\n");
        return -1;
    }

    rdbyt = fread(buff,1,sizeof(buff),fd);
    fclose (fd);
    if(rdbyt<0) {
        printf("read error\n");
        return -1;
    }
    buff[rdbyt] = '\0';
    printf("%s\n",buff);

    match = strstr(buff,"dir=");
    if(match==0) printf("no match\n");
    else {
        sscanf(match,"dir=%s",buff);
    }
    printf("%s\n",buff);

    return 0;

}

运行结果:

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
面向函数的unix环境编程练习
函数调用二维数组例子
数据结构与算法分析(C)1.4
标准C语言IO与Unix/Linux IO API比较
Pipe
磁盘文件操作
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服