编写一个 C 语言程序,通过示例创建、初始化和访问指针变量。在此示例中,我们声明了一个整数值,将其分配给 int 类型的指针,并打印了该指针的值和地址。
#include <stdio.h>
int main()
{
int num;
int *pnum;
pnum = #
num = 200;
printf("Information of the Normal num Variable\n");
printf("num = %d Address of num = %u\n", num, &num);
printf("Information of the Pointer pnum Variable\n");
printf("num = %d Address of num = %u\n", *pnum, pnum);
}

此 程序 创建了一个 char 变量,用一个随机字符初始化,并访问或打印了该字符指针。
#include <stdio.h>
int main()
{
char ch;
char *pch;
pch = &ch;
printf("Please Enter Any Charcater = ");
scanf("%c", &ch);
printf("Information of the ch Variable\n");
printf("num = %c Address of num = %p\n", ch, &ch);
printf("Information of the Pointer pch Variable\n");
printf("num = %c Address of num = %p\n", *pch, pch);
}
Please Enter Any Charcater = o
Information of the ch Variable
num = o Address of num = 0x7ff7b26716af
Information of the Pointer pch Variable
num = o Address of num = 0x7ff7b26716af