当前位置:网站首页>Summary of array knowledge points
Summary of array knowledge points
2022-06-29 07:48:00 【Mertrix_ ITCH】
C Language - Array summary
6、 ... and 、 Array
1. To define an array
Format : Type specifier Array name [ Constant expression ]
- 1.#define N 5 int X[2*N]
- 2.int N=10; int X[N]; //N Can't be a variable
- 3.int X[0…10]; // Illegal expression
- 4.int X[ ]; // Expression cannot be empty
2. Two dimensional array
Format : Type specifier Array name [ Constant expression 1] [ Constant expression 2]
* remarks : Constant expression 1 Not required . eg: int x[ ] [10]
3. Array processing functions <string.h>
- puts(s1): The string s1( With ’\0’ end ) Output to terminal ;
- gets(s1): Input a string from the terminal to the character array s1 in ;
- strcpy(s1,s2): take s2 Copy the contents of to s1 In your storage space , return s1 The first address ;
- strcat(s1,s2): take s2 Content in connects to s1 At the end of , And back to s1 The first address ;
- strlen(s1): Compute string s1 The length of ( With ’\0’ As an end sign ,’\0’ Do not count the array length !);
- strcmp(s1,s2): take s1、s2 Two strings from left to right ( Press ASCII Code size ) Compare character by character , Take the size of the first different character as the comparison result .【s1>s2 The return value is positive ;s1=s2 The return value is 0 ; s1<s2 The return value is negative 】
4. Example
void fun(char *t ,char *s)
{
while(*t!=0) t++; // Formal parameter pointer t The content of is not 0, be t increase 1, Until zero ;
while((*t++=*s++)!=0) // take s The indicated content is assigned to t The address referred to , Then add one to both , until t The contents referred to are 0. 【 amount to :strcat()】
}
边栏推荐
- Detailed explanation of shell condition judgment
- Some examples.
- Appium 环境搭建
- Listen to textarea input through Keyup to change button style
- 1032 Sharing
- Vulnhub's dc7 target
- Select distinct on statement in kingbasees
- 循环嵌套问题:为什么大循环在内,小循环在外可以提高程序的运行效率
- Kingbasees v8r6 cluster maintenance case - data migration between clusters
- 101. 对称二叉树(递归与迭代方法)
猜你喜欢

Listen to textarea input through Keyup to change button style

阿里云访问资源:NoSuchKey

Appium automation test foundation ADB common commands (II)

Concurrent idempotent anti shake

100 lectures on Excel advanced drawing skills (VI) - practical application cases of Gantt chart in project progress

并发幂等性防抖

Perceiving healthy life, enabling boundless connection -- contributing to openharmony 3.1 ecological construction

cv2.cvtColor

Explanation of swing transformer theory

Detailed design of PLC program control system for washing machine
随机推荐
关于KingbaseES临时文件过大问题
ES中配置ext.dic文件不生效的原因
Using cdockablepane to realize floating window in MFC
解题-->在线OJ(十三)
Fluent imitates uiswitch
SQL 注入绕过(六)
postman预处理/前置条件Pre-request
【量化投资系统】因子处理安装talib
JMeter can't find its own jar package imported by BeanShell
从Nacos客户端谈Nacos配置中心
【工控老马】基于PLC的花样喷泉设计原理详解
Viewing application and installation of Hana database license
Markdown skill tree (9): tables
How to permanently set Mysql to utf8 encoding?
Appium 环境搭建
pycharm的虚拟环境如何共享到jupyter-lab
Schnuka: 3D visual recognition system 3D visual inspection principle
软件测试鸾音鹤信
[translation] E-Cloud. Large scale CDN using kubeedge
Markdown skill tree (6): List