#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
void print(int n) //将输入数字的每一位打印出来
{
if (n > 9) //无条件递归会陷入死循环
{
print(n / 10);
}
printf("%d\n", n % 10);
}
int my_strlen(char* str)
{
if (*str != '\0')
{
return 1 + my_strlen(str + 1);
}
else
{
return 0;
}
}
int main()
{
char arr1[20] = { 0 }; //如果不声明元素个数,会产生"stack around the variable 'XXX' was corrupted"的BUG
scanf("%s", arr1);
printf("%s\n", arr1);
unsigned int sum = 0;
scanf("%d",&sum);
print(sum);
char arr[] = "bit";
int len = my_strlen(arr);
printf("len = %d\n", len);
return 0;
}
08-22
532
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-19
1638
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
04-01
6380
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-23
167
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
02-20
806
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)