c语言指针问题,输入函数中*p和p的区别main( ){ int a,b,min ,*pa,*pb,*pmin ;pa=&a; pb=&b; pmin=&min; scanf( "%d%d",pa,pb);printf( "a =%d b = %d \n",a,b);if (*pa > *pb) *pmin = *pb;else *pmin = *pa;printf ("min = %d\n",min);}输入 23 67输
来源:学生作业帮助网 编辑:作业帮 时间:2024/09/06 02:29:12
![c语言指针问题,输入函数中*p和p的区别main( ){ int a,b,min ,*pa,*pb,*pmin ;pa=&a; pb=&b; pmin=&min; scanf(](/uploads/image/z/6846618-66-8.jpg?t=c%E8%AF%AD%E8%A8%80%E6%8C%87%E9%92%88%E9%97%AE%E9%A2%98%2C%E8%BE%93%E5%85%A5%E5%87%BD%E6%95%B0%E4%B8%AD%2Ap%E5%92%8Cp%E7%9A%84%E5%8C%BA%E5%88%ABmain%28+%29%7B+int+a%2Cb%2Cmin+%2C%2Apa%2C%2Apb%2C%2Apmin+%3Bpa%3D%26a%3B+pb%3D%26b%3B+pmin%3D%26min%3B+scanf%28+%22%25d%25d%22%2Cpa%2Cpb%29%3Bprintf%28+%22a+%3D%25d+b+%3D+%25d+%5Cn%22%2Ca%2Cb%29%3Bif+%28%2Apa+%3E+%2Apb%29+%2Apmin+%3D+%2Apb%3Belse+%2Apmin+%3D+%2Apa%3Bprintf+%28%22min+%3D+%25d%5Cn%22%2Cmin%29%3B%7D%E8%BE%93%E5%85%A5+23+67%E8%BE%93)
c语言指针问题,输入函数中*p和p的区别main( ){ int a,b,min ,*pa,*pb,*pmin ;pa=&a; pb=&b; pmin=&min; scanf( "%d%d",pa,pb);printf( "a =%d b = %d \n",a,b);if (*pa > *pb) *pmin = *pb;else *pmin = *pa;printf ("min = %d\n",min);}输入 23 67输
c语言指针问题,输入函数中*p和p的区别
main( )
{ int a,b,min ,*pa,*pb,*pmin ;
pa=&a; pb=&b; pmin=&min;
scanf( "%d%d",pa,pb);
printf( "a =%d b = %d \n",a,b);
if (*pa > *pb) *pmin = *pb;
else *pmin = *pa;
printf ("min = %d\n",min);
}
输入 23 67
输出 a=23 b=67
min=23
我的疑问是第四行:scanf( "%d%d",pa,pb);
这里为什么是pa 和pb ,这样输入的值不是作为a和b的地址吗?(pa=&a)
不是应该用*pa *pb吗
这个程序比较的到底是a和b的值大小还是a和b的地址大小啊
c语言指针问题,输入函数中*p和p的区别main( ){ int a,b,min ,*pa,*pb,*pmin ;pa=&a; pb=&b; pmin=&min; scanf( "%d%d",pa,pb);printf( "a =%d b = %d \n",a,b);if (*pa > *pb) *pmin = *pb;else *pmin = *pa;printf ("min = %d\n",min);}输入 23 67输
scanf要修改pa和pb
函数传递参数的时候只能传递数值
所以你传递papb2个数值过去毫无意义,不能修改变量本身
传递地址的数值过去就有意义了
可以根据地址修改变量本身
这个地址就是指针