# C 语言中的指针

C 语言的指针常常被人们认为是 C 语言中的灵魂所在，可以完成很多高难度的操作。但是更多的人感觉 C 语言的指针的存在如同噩梦一般，因为稍不注意，就会引起灾难性的后果。

## 1. 什么是指针？

``````int *a;
int b=5;
a = &b;
``````

## 2. 示例程序

``````#include <stdio.h>

int main()
{
int *a, b = 100, *c;
printf("a value = %p, a address = %p, a point value = %d\n", a, &a, *a);
printf("b value = %d, b address = %p\n", b, &b);
printf("c value = %p, c address = %p, c point value = %d\n", c, &c, *c);
a = &b;
printf("a value = %p, a address = %p, a point value = %d\n", a, &a, *a);
c = a;
printf("c value = %p, c address = %p, c point value = %d\n", c, &c, *c);
printf("b value = %d, b address = %p\n", b, &b);

return 0;
}
``````

``````a value = 0x7fffaf0005a0, a address = 0x7fffd2942a28, a point value = -1991643855
b value = 100, b address = 0x7fffd2942a24
c value = 0x7fffd2942b20, c address = 0x7fffd2942a30, c point value = 1
a value = 0x7fffd2942a24, a address = 0x7fffd2942a28, a point value = 100
c value = 0x7fffd2942a24, c address = 0x7fffd2942a30, c point value = 100
b value = 100, b address = 0x7fffd2942a24
``````

a 0x7fffaf0005a0 0x7fffd2942a28 -1991643855
b 100 0x7fffd2942a24
c 0x7fffd2942b20 0x7fffd2942a30 1

a 0x7fffd2942a24 0x7fffd2942a28
b 100 0x7fffd2942a24
c 0x7fffd2942a24 0x7fffd2942a30