做單片機項目的時候
[cpp]
void MXFreeP(void* p)
{
free(p)
p = NULL;
}
int main(int argc
{
char* p = NULL;
p = (char*)malloc(
if(NULL != p)
{
*p =
}
MXFreeP(p)
if(NULL == p)
{
printf(
}
else
{
printf(
}
system(
return
}
結果
修改後
[cpp]
void MXFreePP(void** p)
{
free(*p)
*p = NULL;
}
int main(int argc
{
char* p = NULL;
p = (char*)malloc(
if(NULL != p)
{
*p =
}
MXFreePP((void**)&p)
if(NULL == p)
{
printf(
}
else
{
printf(
}
system(
return
}
終於得到期望的結果了
[cpp]
#define MXFreePP(p) free((void*(p))) ; \
printf(
C語言的指針果然深奧
From:http://tw.wingwit.com/Article/program/Java/hx/201311/25832.html