当前位置:网站首页>Half search, character array definition, character array uses D11
Half search, character array definition, character array uses D11
2022-06-26 13:53:00 【Apple ADC】
One . Use half search to learn debugging
Find the premise in half : The data must be in order .
In the length of len Array of arr in , Find keywords key, Successfully returned subscript , Failure to return -1
Two . Character array definition
1. hold drr[10] The elements in are represented in turn
#include<stdio.h>
int main()
{
int arr[]={1,2,3,4};
char brr[10];
short crr[10];
double drr[10]={12.3,34.5,56.7,67.9};
for(int i=0;i<sizeof(drr)/sizeof(drr[0]);i++)
{
printf("%f",drr[]);
}
return 0;
}
2.0 In the form of :0,0.0,false,NULL,'\0'
character : single quote '' One character included , for example 'a','1','0'
character string : Use double quotes "" A string included , from 0 One or more characters , for example " ","1234","adf ab"
There must be a hidden '\0' End of expression '\0' Is the end of the string
Is it a string : Is there any " " perhaps Is there any '\0'
Report errors : Ironing : Local variable uninitialized
int main()
{
char arr[5]={'a','b','c','d','e'};// It's not a string
char brr[10]={'a','b','c','d','e'};// Uninitialized section displays '\0' Is string
char crr[]={'a','b','c','d','e'};// It's not a string
char drr[10];// It's not a string
// Character array specific definitions
char err[]="abcd";
char frr[4]="abcd";// Report errors , There's also a hidden one '\0'
char grr[10]="abcd";
char *hrr="abcd";// String constant contents cannot be modified
}
3、 ... and . The character array uses
#include<stdio.h>
int main()
{
char str1[10]="abcde";// The overall assignment of the whole group has only one initialization opportunity
char str2[10]="xyz";
char str3[10];
str2=str3; // Report errors , You cannot assign values as a whole
str1+=str2;// Report errors
int i;
for(i=0;i!='\0';i++)// Using strings '\0' The closing mark
{
str2[i]=str1[i];
}
str2[i]='\0';// Add end tag '\0'
printf("str1=%s\n str2=%s\n",str1,str2);
return 0;
}
边栏推荐
- Nlp-d60-nlp competition D29
- There are many contents in the widget, so it is a good scheme to support scrolling
- Es6: iterator
- Mysql database explanation (III)
- 8.Ribbon负载均衡服务调用
- mysql配置提高数据插入效率
- Firewall introduction
- MySQL explanation (II)
- Variable declaration of typescript
- MySQL configuration improves data insertion efficiency
猜你喜欢
随机推荐
Calculate the distance between two points (2D, 3D)
Firewall introduction
遍历指定目录获取当前目录下指定后缀(如txt和ini)的文件名
MySQL configuration improves data insertion efficiency
Bigint: handles large numbers (integers of any length)
sed编辑器
团队管理的最关键因素
Here document interaction free and expect automatic interaction
李航老师新作《机器学习方法》上市了!附购买链接
[hcsd application development training camp] one line of code second cloud evaluation article - experience from the experiment process
Reprint - easy to use wechat applet UI component library
ICML 2022 | LIMO: 一种快速生成靶向分子的新方法
Ring queue PHP
Variable declaration of typescript
Echart stack histogram: add white spacing effect setting between color blocks
Wechat applet -picker component is repackaged and the disabled attribute is added -- above
【MySQL从入门到精通】【高级篇】(二)MySQL目录结构与表在文件系统中的表示
Zero basics of C language lesson 7: break & continue
Detailed sorting of HW blue team traceability process
What is the use of index aliases in ES