C中assert(断言)常量const声明外部符号extern

常量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 声明外部符号

编译时错误

链接时错误

运行时错误

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

天乐敲代码

你的鼓励将是我创作最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值