指针的引用传参异常,大神帮忙看看
指针的引用传参错误,大神帮忙看看
#include "stdio.h"
#include "conio.h"
main()
{
int * p1 = NULL;
text(p1);
printf("p1=%d\n",p1);
}
void text(int * &p2) //这里winTC错误
{
int a =1;
*p2 = a;
printf("p2=%d\n",p2);
}
这样写对么,p1指向的值会因为p2指向a而改变么,定义函数text显示错误,不知道为什么
------解决思路----------------------
C++ 语言里面才有引用,C 语言没有
#include "stdio.h"
#include "conio.h"
main()
{
int * p1 = NULL;
text(p1);
printf("p1=%d\n",p1);
}
void text(int * &p2) //这里winTC错误
{
int a =1;
*p2 = a;
printf("p2=%d\n",p2);
}
这样写对么,p1指向的值会因为p2指向a而改变么,定义函数text显示错误,不知道为什么
------解决思路----------------------
C++ 语言里面才有引用,C 语言没有