0
char pt[116];
PT是包含3份分離由消息「:」和最後部分是隨機值重疊
我有存儲在指針的每個值
char* x = strtok(pt, ":") ;
char* y = strtok(NULL, ":") ;
char* z = strtok(NULL, ":") ;
printf("x:%s \n",x);
printf("y:%s \n",y);
printf("z:%s \n",z);
和後來我需要一些字符的第一部分
memcpy(x,strcat(x,".pem"),strlen(x)+4)); //==>this line cause the problem coz
x[strlen(x)]='\0';
printf("%s\n",x);
memcpy(y,y,strlen(y)+strlen(x)+4);
printf("y is :%s\n",y); // here the output is wrong it prints the pem the added part to x
那麼,什麼是建議添加.pem到x沒有重疊memcyp?
你能解釋一下你在導致問題的行中意味着什麼嗎? –
這段代碼沒有意義。 – OldProgrammer
你想做什麼? 'strcat(x,something)'會返回'x'。然後嘗試將'x'複製到'x',但可能使用太多的字節。另一個問題是,我們不知道'strlen(x)'是否意味着調用'strcat'之前或之後的長度,因爲評估參數的順序沒有定義。 –