当前位置:网站首页>数组知识点小结
数组知识点小结
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()】
}
边栏推荐
- How to solve the cross domain problem of mobile phone accessing the web in the web development scenario
- Markdown skill tree (5): picture
- What tools do testers need to know
- Use of LSTM neural network and general neural network
- Is virtual DOM really the fastest?
- Detailed explanation of communication principle between [industrial control old horse] single chip microcomputer and Siemens S7-200
- Dump (cl\alv\tree\base================================cp|set\items\for\column) when expanding node or clicking toolbar button
- Detailed explanation of shell condition judgment
- Listen to textarea input through Keyup to change button style
- 详解Autosar Arxml中的CANFD报文及格式
猜你喜欢

IMX6DL4.1.15支持EIM总线(上)——实际操作,修改内容。

postman预处理/前置条件Pre-request
![[translation] E-Cloud. Large scale CDN using kubeedge](/img/ac/178c078589bb5bc16dbdc8f4ae9525.png)
[translation] E-Cloud. Large scale CDN using kubeedge
How to view software testing training? Do you need training?

Appium automation test foundation ADB common commands (II)

Simulation analysis of sailing dynamics

解题-->在线OJ(十三)

Concurrent idempotent anti shake

Wechat applet learning notes (summer vacation)

【工控老马】单片机与西门子S7-200通信原理详解
随机推荐
TREE ALV 展开Node或者点击Toolbar按钮时DUMP(CL_ALV_TREE_BASE==============CP|SET_ITEMS_FOR_COLUMN)
Schnuka: automatic tire grabbing installation, 3D visual positioning, automatic robot grabbing
tf.count_nonzero
KingbaseES V8R6集群维护案例之--单实例数据迁移到集群案例
Markdown skill tree (4): link
Postman pre request
postman预处理/前置条件Pre-request
SQL 注入绕过(六)
路由详解(九阳真经)
施努卡:什么是视觉定位系统 视觉定位系统的工作原理
MFC中利用CDockablePane实现悬浮窗
Markdown skill tree (2): paragraph and emphasis
What you should know about databases
4 years of working experience, and you can't tell the five communication modes between multithreads. Can you believe it?
Interviewer: why does database connection consume resources? Where are the resources consumed?
[translation] how Bink drives the digital loyalty transactions of some of the largest banks in the UK
KingbbaseES V8R6集群维护案例之---集群之间数据迁移
How to view software testing training? Do you need training?
Appium automation test foundation ADB common commands (II)
Detailed explanation of top and free commands