上午学习总结

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
//函数的递归
//函数递归的两个必要条件 :
// 1.存在限制条件,当满足这个条件则递归不再继续。
// 2.每次递归之后都越来越接近这个限制。
// //若是没有限制则会栈区溢出(《函数栈帧的创建和销毁》)
//练习1 输入1234 打印每个位数上的数字 1 2 3 4
//void print(int n)
//{
//	if (n > 9)
//	{
//		print(n / 10);
//	}
//	printf("%d ", n % 10);
//}
//int main()
//{
//	int sum = 0;
//	scanf("%d", &sum);
//	print(sum);
//	return 0;
//}
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int my_strlen(char* str)
{
	if (*str != '\0')
	{
		return 1 + my_strlen(str + 1);
	}
	else
		return 0;
}
int main()
{
	char arr[] = "abc";
	int len = my_strlen(arr);
	printf("%d", len);
    return 0;
}
// //练习2 编写函数不允许创建临时变量,求字符串长度
//模拟实现strlen
// 非递归使用临时变量
//int my_strlen(char str[])//参数部分写成数组的形式
//int my_strlen(char* str)//参数部分写成指针的形式,因为字符跟数组的传参类似都是传第一个字符的地址,所以可以用指针接受
//{
//	int count = 0;
//	while (*str != '\0')
//	{
//		count++;
//		str++;//找下一个字符
//	}
//	return count;
//}
//int main()
//{
//	int len = my_strlen('abc');
//	printf("%d", len);
//	return 0;
//}
//函数的嵌套
//函数可以相互调用但是不能够嵌套定义
//函数的命名和定义
//命名:可以告诉计算机有这个函数
//在一个头文件中写入一个函数命名 然后在一个.c文件中直接#include "名.h" 便可在源文件中直接用函数,,一般需要导入静态库#pragma comment(lib, "名.lib")(纯在原函数的库)

//链式访问
//int main()
//{
//	printf("%d", printf("%d", printf("%d", 43)));
//	return 0;
//}
//main函数有三个参数
//int main(int argc, char* argc, char* envp[])

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值