当前位置:网站首页>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;
} 边栏推荐
- 古瑞瓦特冲刺港交所上市:创下“多个第一”,获IDG资本9亿元投资
- Es sauvegarde et restauration des données par instantané
- DataGrip配置的连接迁移
- There are many contents in the widget, so it is a good scheme to support scrolling
- Mysql database explanation (IV)
- CVPR 2022文档图像分析与识别相关论文26篇汇集简介
- 微信小程序注册指引
- I met the problem of concurrent programming in an interview: how to safely interrupt a running thread
- Es common grammar I
- Detailed practical sharing, two hours of funny videos after work, earning more than 7000 a month
猜你喜欢
随机推荐
Connection migration for DataGrid configuration
7-16 monetary system I
hands-on-data-analysis 第三单元 模型搭建和评估
Use of wangeditor rich text editor
Tips for using nexys A7 development board resources
7-2 picking peanuts
Bug memory management
Range of types
程序员必备,一款让你提高工作效率N倍的神器uTools
虫子 运算符重载的一个好玩的
7-2 a Fu the thief
Es common grammar I
There are many contents in the widget, so it is a good scheme to support scrolling
Reprint - easy to use wechat applet UI component library
GO语言-管道channel
2021-10-09
imagecopymerge
It is better and safer to choose which securities company to open an account for flush stock
[node.js] MySQL module
Mysql database explanation (IV)









