C/Cpp指针
2015-12-28 16:21
555 查看
C/Cpp指针
参考:
http://en.cppreference.com/w/c/language/pointer动画演示 http://cslibrary.stanford.edu/
https://en.wikibooks.org/wiki/C_Programming/Pointers_and_arrays
http://publications.gbdirect.co.uk/c_book/chapter5/pointers.html
http://publications.gbdirect.co.uk/c_book/chapter5/function_pointers.html
四种“普通”变量
int i; // integer variable ‘i’ 变量i里面放int型值,用int规则来访问int *p; // pointer ‘p’ to an integer 变量p里面只能放地址(即指针),用pointer规则来访问
int a[]; // array ‘a’ of integers 数组,连续存储着的同型变量
int f(); // function ‘f’ with return value of type integer 函数,把f用function规则来访问
其中:
int arr[10]; // arr is an array of 10 const ints
int arr[5]; printf("length is: %ld and %ld", sizeof(arr[0]), sizeof(arr)); //运行结果: length is: 4 and 20
int **pp; // pointer ‘pp’ to a pointer to an integer
int (*pa)[]; // pointer ‘pa’ to an array of integer
int (*pf)(); // pointer ‘pf’ to a function with return value integer
int *ap[]; // array ‘ap’ of pointers to an integer
int *fp(); // function ‘fp’ which returns a pointer to an integer
int ***ppp; // pointer ‘ppp’ to a pointer to a pointer to an integer
int (**ppa)[]; // pointer ‘ppa’ to a pointer to an array of integers
int (**ppf)(); // pointer ‘ppf’ to a pointer to a function with return value of type integer
int *(*pap)[]; // pointer ‘pap’ to an array of pointers to an integer
int *(*pfp)(); // pointer ‘pfp’ to function with return value of type pointer to an integer
int **app[]; // array of pointers ‘app’ that point to pointers to integer values
int (*apa[])[]; // array of pointers ‘apa’ to arrays of integers
int (*apf[])(); // array of pointers ‘apf’ to functions with return values of type integer
int ***fpp(); // function ‘fpp’ which returns a pointer to a pointer to a pointer to an int
int (*fpa())[]; // function ‘fpa’ with return value of a pointer to array of integers
int (*fpf())(); // function ‘fpf’ with return value of a pointer to function which returns an integer
相关文章推荐
- Python调用C/C++动态链接库的方法
- TsinghuaX: 00740043X C++语言程序设计基础 第五章提纲
- C++学习:字符串分割函数
- TsinghuaX: 00740043X C++语言程序设计基础 第四章提纲
- TsinghuaX: 00740043X C++语言程序设计基础 第三章提纲
- TsinghuaX: 00740043X C++语言程序设计基础 第二章提纲
- 高质量C++编程之第1章 文件结构
- 取字符串的长度strlen()函数
- C++11杂记
- TsinghuaX: 00740043X C++语言程序设计基础 第一章提纲
- 一个简单的C++程序及说明
- C语言中的位域、字节序、比特序、大小端
- 【转载】C++中的基类与派生类
- Problem A: C语言习题5.9--整数n和m之间的素数个数
- C++ Virtual
- C++入门(5):定义个人函数
- C++ 大规模程序设计 之 包
- C/Cpp的 typedef
- C语言复习(1)
- Problem H: C语言实验——数组逆序