当前位置:网站首页>数组知识点小结
数组知识点小结
2022-06-29 06:40:00 【Mertrix_ITCH】
六、数组
1.数组定义
格式:类型说明符 数组名[常量表达式]
- 1.#define N 5 int X[2*N]
- 2.int N=10; int X[N]; //N不能为变量
- 3.int X[0…10]; //非法表达式
- 4.int X[ ]; //表达式不能为空
2.二维数组
格式:类型说明符 数组名 [常量表达式1] [常量表达式2]
*备注:常量表达式1可不填。 eg: int x[ ] [10]
3.数组处理函数 <string.h>
- puts(s1):将字符串s1(以’\0’结束)输出到终端;
- gets(s1):从终端输入一个字符串到字符数组s1中;
- strcpy(s1,s2):将s2中的内容复制到s1的储存空间中,返回s1的首地址;
- strcat(s1,s2):将s2中的内容连接到s1的末尾,并返回s1的首地址;
- strlen(s1):计算字符串s1的长度(以’\0’作为结束标志,’\0’不计入数组长度!);
- strcmp(s1,s2):将s1、s2两个字符串自左向右(按ASCII码大小)逐个字符相比较,以第一个不相同的字符的大小作为比较结果。【s1>s2 返回值为正 ;s1=s2 返回值为0 ; s1<s2 返回值为负】
4.例题
void fun(char *t ,char *s)
{
while(*t!=0) t++; //形参指针t的内容不为0,则t增1,直到指零为止;
while((*t++=*s++)!=0) //将s所指内容赋值给t所指地址,然后两者同时加一,直到t所指的内容为0. 【相当于:strcat()】
}
边栏推荐
- SAP ui5 Beginner (I) Introduction
- 1183:病人排队
- Deploy Prometheus server service system management
- Reflection modification final
- ES中配置ext.dic文件不生效的原因
- Two ways to write throttling - recently seen
- Markdown skill tree (9): tables
- 蓝桥杯——最小框架
- SYSTEMd management node exporter
- Unexpected exception ... code: Badrequest when downloading Xilinx 2018.2
猜你喜欢
随机推荐
[FreeRTOS] interrupt mechanism
Roblox sword nine sword two
施努卡:3D视觉识别系统 3D视觉检测原理
Perceiving healthy life, enabling boundless connection -- contributing to openharmony 3.1 ecological construction
【工控老马】PLC六路抢答器系统设计详解
Markdown skill tree (8): code blocks
[industrial control old horse] detailed explanation of design principle of pattern fountain based on PLC
Markdown skill tree (3): title
What you should know about databases
systemd 管理node-exporter
excel高级绘图技巧100讲(六)-甘特图在项目进度上的实战应用案例
施努卡:什么是视觉定位系统 视觉定位系统的工作原理
Schnuka: 3D visual inspection scheme 3D visual inspection application industry
呕心沥血总结出来的MySQL常见错误以及解决方法(一)
4 years of working experience, and you can't tell the five communication modes between multithreads. Can you believe it?
How to talk about salary correctly in software test interview?
Blue Bridge Cup - minimum frame
101. 对称二叉树(递归与迭代方法)
面试官:为什么数据库连接很消耗资源,资源都消耗在哪里?
tf.count_nonzero









