当前位置:网站首页>First knowledge of the second bullet of C language
First knowledge of the second bullet of C language
2022-06-27 22:40:00 【Meow meow more】
List of articles
One . Constant
Constant : Describe invariant quantities .C Constants in languages are divided into the following categories : Literal constants const Modified constant variable #define Defined identifier constant Enumeration constants .
1. Literal constants : 30; 3.14;‘w’ character ;“abc” character string ;
2.const Modified constant variable
const Embellished a No output 20, If there is no const Will output 20, Make variable a Properties with constants
3.#define Defined identifier constant
Output 100 100 define The identifier is defined MAX So you can output
4. Enumeration constants
Can't change
Two . character string + Escape character + notes
character string
int main()
{
//char Character type
//‘a’- character constants
char ch=‘w’; // Alphabet character w Put it in a character variable to define
//“abcdef”;- Called string
//C There is no string type in the language
return 0;
}
How to save strings ?
Put it in the character array
char arr[10] -- Put... In the array 10 Characters ; for example :char arr[10]=“abcdef” This can store , The premise is that the space given in front is large enough perhaps char arr[]=“abcdef” -- This automatically determines the previous value according to the size of the subsequent string
A... Is hidden at the end of the string ’’
‘’ Flag for the end of the string
The initialization of the arr1 Occupied 7 Space , Initialization arr2 Account for the 6 Space
%s Print out characters
arr1 and arr2 There is memory space before and after the , The output only accounts for a small part
arr1 The output is that because ’’ and arr2 The output of does not ’’, therefore arr2 The output is as shown in the figure , Until I find ’’ Before printing
This is adding ’’ Then you can output the same
Want to run this program , Find the length of this string , If you use this function, you need to add a header file before it #include <string.h>
strlen Get the length of the string So it is 6
The above 7 Is the length of space occupied by this string (size of) Need to be 7
Escape character : Changed the meaning of the original characters
C An escape character specified in a language
Escape character
// Three letter words ( Early parsers )
) -->]
( -->[
When the path is printed, it must be
For horizontal tabs , amount to tab
Convert octal numbers to decimal numbers , Find the decimal representation of ASCII Value instead of character This is a character in the figure
if C Nested annotations in a language can cause problems therefore C The annotation style of the language does not support nesting
//-C++ The annotation style of
Write comments for your own code when you write code in the future ( Comb your mind 、 Explain complex code )
3、 ... and . Select statement
if The choice statement of
if…else if if( Expression is true ) execute if If false, execute else
C The language implements the selected statement :if…else Switch…
Four . Loop statement
5、 ... and . function
This is the corresponding function in mathematics . and C The corresponding functions in the language are as follows :
First of all, define a add function , hold int x int y To assign separately to n1 n2
add- Function name x y For function parameters {} In is the function body int Is the return type The above definition can also be changed to
6、 ... and . Array
Originality is not easy. ; I also hope you guys can support !
边栏推荐
- Codeforces Round #717 (Div. 2)
- Day8 - cloud information project introduction and creation
- 渗透学习-sql注入过程中遇到的问题-针对sort=left(version(),1)的解释-对order by后接字符串的理解
- OpenSSL programming I: basic concepts
- 渗透学习-靶场篇-pikachu靶场详细攻略(持续更新中-目前只更新sql注入部分)
- regular expression
- Structured machine learning project (I) - machine learning strategy
- MySQL数据库 实验报告(一)
- Ellipsis after SQLite3 statement Solutions for
- go语言切片Slice和数组Array对比panic: runtime error: index out of range问题解决
猜你喜欢
Login credentials (cookie+session and token token)
Crontab scheduled task common commands
netERR_CONNECTION_REFUSED 解决大全
渗透学习-靶场篇-dvwa靶场详细攻略(持续更新中-目前只更新sql注入部分)
二维数组中修改代价最小问题【转换题意+最短路径】(Dijkstra+01BFS)
结构化机器学习项目(二)- 机器学习策略(2)
It smells good. Since I used Charles, Fiddler has been completely uninstalled by me
crontab定时任务常用命令
Transformation from student to engineer
[MySQL] database function clearance Tutorial Part 2 (window function topic)
随机推荐
average-population-of-each-continent
Exclusive interview with millions of annual salary. What should developers do if they don't fix bugs?
Infiltration learning - problems encountered during SQL injection - explanation of sort=left (version(), 1) - understanding of order by followed by string
Start the start php
Use Fiddler to simulate weak network test (2g/3g)
Go from introduction to actual combat - task cancellation (note)
Contest 2050 and Codeforces Round #718 (Div. 1 + Div. 2)
Learn to go concurrent programming in 7 days go language sync Application and implementation of cond
对话乔心昱:用户是魏牌的产品经理,零焦虑定义豪华
Common APIs (Methods) for scope -number and string
Basic knowledge of loop traversal and function
Day8 - cloud information project introduction and creation
Typescript learning
Remote invocation of microservices
Memoirs of actual combat: breaking the border from webshell
Basic data type and complex data type
Is it safe to open a stock account through the account opening link given by the CICC securities manager? I want to open an account
清华大学教授:软件测试已经走入一个误区——“非代码不可”
The problem of minimum modification cost in two-dimensional array [conversion question + shortest path] (dijkstra+01bfs)
CDH集群之YARN性能调优