【发布时间】:2013-12-11 16:52:00
【问题描述】:
例如:
void Sample_Function(char * ptr){ //Stuff }
void Some_Other_Function(){
char *p;
p = malloc(sizeof(char)*5);
// Is this correct?
Sample_Function(p);
// Or this?
Sample_Function(*p);
}
因为 free() 需要一个地址而不是指向的字节,我猜第一个选项是正确的?
另外,对于返回指针的函数:
// Is this correct?
return p;
// Or this?
return *p;
感谢您的帮助!
【问题讨论】:
标签: c pointers parameter-passing