方法一:
config.ini:
[server]
ip=192.168.1.150
port=8888
.cpp:
#include
cstring configpath,ipstring;
getcurrentdirectory(100,configpath.getbuffer(100)); //為configpath開闢空間,獲取當前工程路徑
configpath.releasebuffer(); //釋放多餘空間
configpath += "\\config.ini";
getprivateprofilestring("server","ip",null,ipstring.getbuffer(20),20,configpath);
int port=getprivateprofileint("server","port",8887,configpath);
printf("%s\n",configpath);
printf("%s\n",ipstring);
printf("%d",port);
方法二:
#include
;#include
;#include
;int main(int argv,char **argc)
ini=fopen(argc[1],"r");
while(!feof(ini))
}printf("\n");
return 0;
}
讀配置檔案
tchar szpath max path memset szpath,0,sizeof szpath getmodulefilename null,szpath,max path cstring strpath szpath strpath strpath.left strpath.reverse...
讀配置檔案2
資料 host 1 ip 16.173.234.228 port 21,80,873,3306 cpu 10 freemem 3 conconn 1000 checkgw 1 freedisk 10 swapused 30000 host host 2 ip 16.173.235.25 port 2...
Php讀配置檔案
馬永佔,myz,mayongzhan php讀配置檔案 馬永佔,myz,mayongzhan 要讀的格式 php.ini this is demo by 馬永佔 myz global i 1j 2 k 3 self a 11 b 22 c 33 讀的方法 name test4.php date mo...