1.get()函数;为什么不安全:
因为它可以无线读取,而且不会判断上限;任何一个程序员都应该确保buffer的空间足够大,以便能在执行操作的时候不发生溢出,从而导致程序崩溃。
它可以用fgets()函数进行替换;
2.时间复杂度是执行次数和问题规模之间的函数问题。
空间复杂度是额外辅助空间和问题规模的函数关系。
在进行时间复杂度的计算式有俩个原则:一只保留高阶项,二系数不保留。
3.关于const;(左值写权限,右值读权限)
一const把变量设置为只读;
二数据类型对于const透明;
例如:const int *cp == int const *cp
三const直接修饰的内容(右边的值)不能作为左值,即const封锁了它的写权限;
四权限只能平等传递或者缩小传递。
例如:
int a = 10;
int b = 20;
const int ca = 100;
int *p = &a;
p = &ca;错误:无法从“const int *”转换为“int *;
*p = 200;
const int *cp1 = &a;
cp1 = &ca;
*cp1 = 200;错误:cp1已经是只读的权限,不能给常量辅助;
int b = 20;
const int ca = 100;
int *p = &a;
p = &ca;错误:无法从“const int *”转换为“int *;
*p = 200;
const int *cp1 = &a;
cp1 = &ca;
*cp1 = 200;错误:cp1已经是只读的权限,不能给常量辅助;
int *const cp2 = &a;
int *const cp3 = &ca;错误:权限不能放大传递,只能平等或者缩小传递;
int *const cp3 = &ca;错误:权限不能放大传递,只能平等或者缩小传递;
p = (int *)&ca;
*p = 200;
*p = 200;