c语言使用配置文件 c语言怎么加载自己写的配置文件?

c语言怎么加载自己写的配置文件?用C语言读取属性配置文件的方法:1。在配置路径下找到属性文件2。逐行读取文件内容具体实现代码如下://define the Read line array,1024 l

c语言怎么加载自己写的配置文件?

用C语言读取属性配置文件的方法:

1。在配置路径下找到属性文件

2。逐行读取文件内容

具体实现代码如下:

//define the Read line array,1024 line

char line[1024

//store the configuration item array setting

int setting[n],I=0

//start the loop reading

while(fgets,line,1024)=Null)

{

//读取行变量的配置值

fscanf(line,“setting%*d%d”,&setting[i])}

此代码没有问题。请注意,写入文件时,格式应为&fwrite[i],sizeof(struct student),1,FP)