作者:
a942195 (Truth)
2014-11-10 23:09:04最近在版子上要從server端下載更新檔來更新
int download_file(char *img[][2],int count){
char cmd[128] = {0};
int i;
//strcat(cmd,"wget -O /data/update.xml'");
for( i=0;i<count;i++){
strcat(cmd,"wget ");
strcat(cmd,"-O /Data/");
strcat(cmd,img[i][0]);
strcat(cmd," ");
strcat(cmd,"\"");
strcat(cmd,url);
strcat(cmd,"?");
strcat(cmd,"&img_name=");
strcat(cmd,img[i][0]);
strcat(cmd,"&token=");
strcat(cmd,token_decrypt);
strcat(cmd,"\"");
system(cmd)
memset(cmd,0,sizeof(cmd));
}
但是發現到下載到的檔案跟原本的檔案大小差很多 而且還會出現segmentation fault
不知道這樣的寫法對不對 想說會不會是同步下載的關係 難道不能等一個下載玩
在接下一個嗎?
作者:
qsort (Cos)
2014-11-12 08:47:00char *img[][2]有點怪,img ia a array pointers to char[2]所以你每個image name最多就兩個char, 扣掉\0, 剩一個char請問你的檔名是"a"這類的嗎?再來是,請不要用strcat, 那是下流的寫法int len=0; //reset buff to headlen+=snprintf(buff+len,sizeof(buff)-len,format,...);建議把snprintf學起來,strcat真的不要再用了。嗯, 總結: 請愛用script.