标签:clu ror file class nbsp open size end div
#include <stdio.h> #include <string.h> #include <stdlib.h> //命令: ./a.out file //功能: 将file读取到buffer,然后打印出来 int main(int argc, char *argv[]) { char buf[1024] = {}; FILE *fp = NULL; int ret; fp = fopen(argv[1], "r"); ret = fread(buf, sizeof(char), sizeof(buf), fp); if (ret <= 0) { printf("fread end or error!\n"); return -1; } printf("readCharNum= %d\n", ret); //打印读取file的字符数 printf("buf = %s\n", buf); //打印file的内容 return 0; }
#include <stdio.h> #include <string.h> #include <stdlib.h> //命令: ./a.out file //功能: 将file读取到buffer,然后打印出来 int main(int argc, char *argv[]) { char buf[1024] = {}; FILE *fp = NULL; int ret; fp = fopen(argv[1], "r"); ret = fread(buf, sizeof(char), sizeof(buf), fp); if (ret <= 0) { printf("fread end or error!\n"); return -1; } printf("readCharNum= %d\n", ret); //打印读取file的字符数 printf("buf = %s\n", buf); //打印file的内容 return 0; }
标签:clu ror file class nbsp open size end div
原文地址:http://www.cnblogs.com/linuxAndMcu/p/7582691.html