


Introduction to C language: talk about basic knowledge (data types, variables, functions, arrays, etc.)
This article will help you learn C language and talk about the basic knowledge of C language (data types, variables, functions, arrays, etc.). I hope it will be helpful to everyone!
What is C language
- Simply put
C language is a computer language , widely used in low-level development, using the language to write code programs and solve problems
So for the computer major, C language and learning C language are very important
Computer Language Development
As far as computers are concerned, the initial implementation of binary code (1/0) was achieved by powering on the computer to communicate with the computer and then forming a binary code
But It was too troublesome, so we developed mnemonics (assembly language), and then formed the B language, and then developed the C language
And then various interpreted languages appeared (Java, python, etc.)
Write the first C language code
- Tools
Recommended VS2019 compiler
Basic format
#include<stdio.h> //内是头文件名称;stdio代表standard input output; 即标准输入输出头文件(与后面所执行任务要用的库语言所关联) int main() //主函数,程序的入口(有且只有一个); { //int 代表整型;即表示main函数调用返回整型值 任务; return 0; }</stdio.h>
Data type
char character short (int) short integer type int integer type long (int) long integer type long long (int) long integer type
float single-precision floating-point type double double-precision floating-point type (integer type is used for integers, and floating point type is used for decimals)
There are so many data types, it is for more convenience It’s good to apply for memory space from computer (try to save space and optimize memory )
unit
From the above The memory applied for each data type is: 1 2 4 4 8 4 8 (unit bytes, individual differences vary depending on the number of computers)
Example; short is 2 bytes, which is 16 bits (binary)
Range: the minimum is all 0, which means 0; the maximum is all 1, the range obtained by the weight bit is 2*10^16-1
Variables
- Type
Variables are divided into local variables and global variables
Scope
Local variables: In the local scope where local variables are located
Global variables: the entire project
Life cycle
Local variables: the period starts when entering the local scope and ends when leaving
Global variables: the life cycle of the program
Note: When the defined variable has the same name, the local priority## in the local scope #;
C language and law stipulate thatvariables must be defined at the front of the current code block.
Constant Type of constant in C language:
- Literal constant: 3.14, "abc", etc.
- Constant variables modified by const: const—constant attributes, the essence is constants defined by variables
- #define: Example: #define MAX 100
- Enumeration constants: enum Enumeration: enumerate one by one; Example: enum Sex {male, female, secret}
Function
In the coding process, it is inevitable to encounter the repeated use of a certain set of statements. Creating a function at this time can make coding much easier and faster - simplifying reuse.
- For example, create an addition function (custom)
int Add(int x, int y) { int z = 0; z = x + y; return z; } int main() { int a = 10; int b = 20; int ret = 0; ret = Add(a, b); printf("%d\n", ret) return 0; }
Array
The array is an Grouping a collection of elements of the same type
- Creating an array is also equivalent to applying for space from the computer. It is a connected space with a label
- For this array, its label starts from 0 Initially, the elements in the array are generally accessed in the form of array subscripts
- The array name is also a special address
Operator
Arithmetic: Multiply* Division/Remainder % Addition Subtraction-
Shift (2 Base): First represent the number in binary and shift it, and then represent it into the corresponding number after the shift位操作
- 按位于:两个数以二进制竖着排列,有0则为0,都是1才为1
- 按位或:两个数以二进制竖着排列,有1则为1,都是0才为0
- 按位于:两个数以二进制竖着排列,相同则为0,相异才为1
赋值
注意区别=与==:一个是赋值,一个是判断相等
单目操作
(操作数个数决定是单还是其他,例 1+2:1和2是操作数,为双目操作符)
关系/逻辑/条件
- 解释: 表达式1成立,结果为表达式2,否则为3
逗号表达式
- 解释:从左向右依次计算,结果去最后一个表达式
关键字
字符串
定义
即“ ”中的内容(例:“abc”)
结束标志
- “\0”(\0不做字符串的内容)
- 注:字符串可以存放在字符数组中;C语言无字符串类型
局别
- 示图1中的arr2数组元素型初始化,它的长度未定义,会随机生成,直到遇到“\0”,来结束字符串
求字符串长度
sizeof(arr[])计算内容包括“\0”,算作一个bite
strlen(arr)不包括“\0”,计算字符串内容长度(需要审引库函数—
)
转义字符
\0是一个字符,还有\t,\n等代表不同意思的字符
转义字符则是转变原来的意思
例如你想单纯打印\n,那么则需要在“\n”前再打一个“\”,来转变“\n”原本的意思
注释
注释即用来注明,解释代码步骤的意思,让自己和读者能更好的理解
C语言——/* */ C++——//
- 注意:除了用来解释,还可以删除不需要的代码;注解不能嵌套使用
选择语句
if(条件) 多选择:if(条件) 执行语句; 执行语句; else \\反之 else if(条件) 执行语句; 执行语句; else...
循环
while循环: 初始化; while(条件) { 执行和调整语句;} for循环 for(初始化;条件;调整) { 执行语句; } do while循环 do { 执行和调整语句;} while(条件)
注:while先判断条件,符合再执行语句,而do while循环先执行语句,再判断条件是否再进行循环;在长幅篇的代码中,用for循环比较适合,用while不利于更改如果有需要的话
相关推荐:《C视频教程》
The above is the detailed content of Introduction to C language: talk about basic knowledge (data types, variables, functions, arrays, etc.). For more information, please follow other related articles on the PHP Chinese website!

The latest developments and best practices in C#.NET development include: 1. Asynchronous programming improves application responsiveness, and simplifies non-blocking code using async and await keywords; 2. LINQ provides powerful query functions, efficiently manipulating data through delayed execution and expression trees; 3. Performance optimization suggestions include using asynchronous programming, optimizing LINQ queries, rationally managing memory, improving code readability and maintenance, and writing unit tests.

How to build applications using .NET? Building applications using .NET can be achieved through the following steps: 1) Understand the basics of .NET, including C# language and cross-platform development support; 2) Learn core concepts such as components and working principles of the .NET ecosystem; 3) Master basic and advanced usage, from simple console applications to complex WebAPIs and database operations; 4) Be familiar with common errors and debugging techniques, such as configuration and database connection issues; 5) Application performance optimization and best practices, such as asynchronous programming and caching.

C# is widely used in enterprise-level applications, game development, mobile applications and web development. 1) In enterprise-level applications, C# is often used for ASP.NETCore to develop WebAPI. 2) In game development, C# is combined with the Unity engine to realize role control and other functions. 3) C# supports polymorphism and asynchronous programming to improve code flexibility and application performance.

C# and .NET are suitable for web, desktop and mobile development. 1) In web development, ASP.NETCore supports cross-platform development. 2) Desktop development uses WPF and WinForms, which are suitable for different needs. 3) Mobile development realizes cross-platform applications through Xamarin.

The C#.NET ecosystem provides rich frameworks and libraries to help developers build applications efficiently. 1.ASP.NETCore is used to build high-performance web applications, 2.EntityFrameworkCore is used for database operations. By understanding the use and best practices of these tools, developers can improve the quality and performance of their applications.

How to deploy a C# .NET app to Azure or AWS? The answer is to use AzureAppService and AWSElasticBeanstalk. 1. On Azure, automate deployment using AzureAppService and AzurePipelines. 2. On AWS, use Amazon ElasticBeanstalk and AWSLambda to implement deployment and serverless compute.

The combination of C# and .NET provides developers with a powerful programming environment. 1) C# supports polymorphism and asynchronous programming, 2) .NET provides cross-platform capabilities and concurrent processing mechanisms, which makes them widely used in desktop, web and mobile application development.

.NETFramework is a software framework, and C# is a programming language. 1..NETFramework provides libraries and services, supporting desktop, web and mobile application development. 2.C# is designed for .NETFramework and supports modern programming functions. 3..NETFramework manages code execution through CLR, and the C# code is compiled into IL and runs by CLR. 4. Use .NETFramework to quickly develop applications, and C# provides advanced functions such as LINQ. 5. Common errors include type conversion and asynchronous programming deadlocks. VisualStudio tools are required for debugging.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Notepad++7.3.1
Easy-to-use and free code editor

Zend Studio 13.0.1
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Atom editor mac version download
The most popular open source editor
