16.字符串处理函数——字符串长度函数

文章目录


前言

本系列为字符串处理函数编程题,点滴成长,一起逆袭。


一、题目描述


二、解题

程序运行代码

c 复制代码
#include<stdio.h>
#include<string.h>
int main() {
	char str[ ]="0123\0456789";
	char str1[]="0123\0abced";
	char str2[]="\x69\082\n";
	char str3[]="\t\v\\\0wil\\n";
	char str4[]={'a' ,'\0','b','ç'};
	
	puts(str);
	printf("%d\n",strlen(str));
	puts(str1);
	printf("%d\n",strlen(str1));
	puts(str2);
	printf("%d\n",strlen(str2));
	puts(str3);
	printf("%d\n",strlen(str3));
	puts(str4);
	printf("%d\n",strlen(str4));
	return 0;
}


总结

字符串长度函数

格式:int strlen(字符串)到\0结束

实际长度,不包括'\0'在内)

相关推荐
沐苏瑶1 小时前
Java 搜索型数据结构全解:二叉搜索树、Map/Set 体系与哈希表
java·数据结构·算法
ccLianLian2 小时前
深度学习·DDPM
数据结构
ZoeJoy82 小时前
算法筑基(二):搜索算法——从线性查找到图搜索,精准定位数据
算法·哈希算法·图搜索算法
Alicx.3 小时前
dfs由易到难
算法·蓝桥杯·宽度优先
_日拱一卒3 小时前
LeetCode:找到字符串中的所有字母异位词
算法·leetcode
云泽8083 小时前
深入 AVL 树:原理剖析、旋转算法与性能评估
数据结构·c++·算法
Wilber的技术分享4 小时前
【LeetCode高频手撕题 2】面试中常见的手撕算法题(小红书)
笔记·算法·leetcode·面试
邪神与厨二病4 小时前
Problem L. ZZUPC
c++·数学·算法·前缀和
梯度下降中5 小时前
LoRA原理精讲
人工智能·算法·机器学习
IronMurphy5 小时前
【算法三十一】46. 全排列
算法·leetcode·职场和发展