我有一個指向 poinetr 的指標,我將其作為引數使用 char **image
現在我想將它分配給字符指標,這樣如果我分配disk然后呼叫函式test可以釋放它影像和磁盤也將被釋放。在C中可能嗎?這是我的函式,呼叫函式正在呼叫,影像是指向指標引數的指標。我稱這個函式為char *image="hello";test("hello",&image)
int32_t test(const char *path,char **image){
*(char *)(&disk) =*image;
34 printf("ya %s\n",*disk);
uj5u.com熱心網友回復:
*(char *)(&disk)
^^^^^ take the address of disk (with type "pointer to type of disk")
^^^^^^^^^ ^ convert that to a pointer to char
^ and finally get the single char pointed to by that mess
*(char *)(&disk) = *image; // nope, you cannot assign a pointer to char to a char.
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/373388.html
標籤:C
上一篇:c中的鏈表回傳負數而不是添加節點
