1.指针类型一致,运算以相应类型变量为单位
2.int a[10]; a为数组的第一个元素地址,数组地址为&a
3.非规则2维数组:
char *a[2] = {};
a[0] = new int;
a[1] = new int[5];
4.char str[256]; cin.getline(str, 256); string str; getline(cin, str);读取一行包括空格
5.统计字符串中字符个数:int a[256]; a[str[i]]++;
6.const int *p; 不用初始化;常指针int *const p = &n;必须要初始化化;
7.void *p = NULL; int n = 100; p = &n; cout<<*(int *)p<<endl;
8.char a[] = "hello"; char *p = "hello"; sizeof(a) = 6; sizeof(p) = 4; a为数组,p为指针变量
9.#include <cstdlib> atof(c风格字符串);
10.f(int &i); f(300);报错;f(const int &i); f(300);不报错,允许常量初始化,禁止使用这个引用
11.尽量使用引用传递参数,尽量使用const限制对引用的修改
12.全局变量、静态变量会使用默认初始化
13.函数指针:
void (*f)(int a, int b) = NULL;
void f1(int a, int b);
f = f1;
f(5, 6);
14.不允许输出函数指针的值
15.int a[20] = {}; memset(a, 'a', 19); cout<<(char*)a<<endl;正常通过19个a,要初始化;