指针的基本应用
#include<stdio.h>
int main()
{
int a = 100, b = 200;
int* p_1, * p_2 = &b;
p_1 = &a;
printf("a=%d\n", a);
printf("*p_1=%d\n", *p_1);
printf("b=%d\n", b);
printf("*p_2=%d\n", *p_2);
return 0;
}
不同数据类型的指针的存储大小都是4(在32位系统下)
#include<stdio.h>
int main()
{
char* p1;
short int* p2;
int* p3;
long int* p4;
float* p5;
double * p6;
printf("sizeof(p1)=%d\n", sizeof(p1));
printf("sizeof(p2)=%d\n", sizeof(p2));
printf("sizeof(p3)=%d\n", sizeof(p3));
printf("sizeof(p4)=%d\n", sizeof(p4));
printf("sizeof(p5)=%d\n", sizeof(p5));
printf("sizeof(p6)=%d\n", sizeof(p6));
return 0;
}
标签:p2,p3,int,例子,-----,printf,sizeof,指针 From: https://www.cnblogs.com/Miraitowajwj/p/17086654.html