常量const
:修饰变量,这个变量就被称为常变量,不能被修改,但是本质上还是变量。
const修饰指针变量的时候
如果放在*的左边,修饰的是*p,表示的是指针所指向的内容,。是不能通过指针来改变的。
但是指针变量本身可以修改的。
int const * const* p
const修饰指针变量的时候
如果放在*的右边,修饰的是指针变量p,表示指针变量不能被改变
但是指针的内容,可以被改变。
NULL空指针不能解引用操作,不能直接解引用访问的。
#include<assert.h>断言
assert
strlen自定义
#include<string.h>
#include<stdio.h>
#include<assert.h>
int my_strlen(const char* llong)
{
int i = 0;
/*for (i = 0; i <= llong; i++)
{
return llong;
}*/
assert(llong != NULL);
while (*llong != '\0')
{
*llong++;
i++;
}
return i;
}
int main()
{
char arr1[20] = "xxxxxxxxx";
my_strlen(arr1);
printf("%d", my_strlen(arr1));
return 0;
}
函数默认返回类型为整形
size_t-------unsigned int
extern 声明外部符号
编译时错误
链接时错误
运行时错误