一、介绍
在做项目需要配置的参数一般保存在文件,读取文件配置比较简单的方法就是按行读取
二、程序
#includeint main() { FILE *fp=NULL; unsigned int tmp = 0; fp = fopen("config.txt", "r"); while(!feof(fp)) { fscanf(fp, "%xrn", &tmp); printf("tmp:%xn",tmp); } fclose(fp); return 0; }
测试文件
config.txt
1234 1234
编译
gcc testfile.c -o testfile
测试



