How do you convert void pointer to char pointer in C

前端 未结 2 413
北恋
北恋 2020-12-31 04:10

Ok this has been become sooo confusing to me. I just don\'t know what is wrong with this assignment:

void *pa; void *pb;
char *ptemp; char *ptemp2; 

ptemp =         


        
2条回答
  •  感情败类
    2020-12-31 04:40

    I just tried your code in a module called temp.c. I added a function called f1.

    void *pa; void *pb;
    char *ptemp; char *ptemp2;
    
    f1()
    {
            ptemp = (char *)pa;
            ptemp2 = (char *)pb;
    }
    

    On Linux I entered gcc -c temp.c, and this compiled with no errors or warnings.

    On which OS are you trying this?

提交回复
热议问题