c語言使用配置文件 c語言怎么加載自己寫的配置文件?
c語言怎么加載自己寫的配置文件?用C語言讀取屬性配置文件的方法:1。在配置路徑下找到屬性文件2。逐行讀取文件內(nèi)容具體實現(xiàn)代碼如下://define the Read line array,1024 l
c語言怎么加載自己寫的配置文件?
用C語言讀取屬性配置文件的方法:
1。在配置路徑下找到屬性文件
2。逐行讀取文件內(nèi)容
具體實現(xiàn)代碼如下:
//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])}
此代碼沒有問題。請注意,寫入文件時,格式應(yīng)為&fwrite[i],sizeof(struct student),1,F(xiàn)P)