想用个数组读配置文件,不知道怎么写
文件内容
[list]item_no=4item0 = 0, 0, 0,item1 = 200, 1, 0, \B003\C048008\fk3232\c255000000000\S05\s000255000000hi, 你好item2 = 30, 4, 3, \ct\b255255000000\C000008abcitem3 = 500, 20, 5, \N02
for(i=0;i<item_no;i++){ item[i]=GetPrivateProfileString(lpSection,lpKey,lpValue,/*这里怎么写?*/,iBufferSize,lpPath);}char str[255]; for(i=0;i<item_no;i++){ sprintf(str,"item%d",i); item[i]=GetPrivateProfileString(lpSection,lpKey,lpValue, str,iBufferSize,lpPath);}
[解决办法]
// 读出有多少itemint num_items = read_item_number();// 分配空间int* store = (int*) malloc( 3 * num_items * sizeof(int) );// 读出每个itemint a,b,c;for (int i=0; i<num_items; i++) { read_next_item( &a, &b, &c ); store[3*i] = a; store[3*i+1] = b; store[3*i+2] = c;}