Basic grammar of C language

1. Create a new project in VS Code
1. Double-click VS 2022 to enter the lower interface, click to create a new project

insert image description here
2. Select an empty project, click Next
insert image description here
3. Configure the name and location for the project you created
insert image description here
4. Click Create to get the following interface
insert image description here
5 .Click the source file, right mouse button—new project—select C++ file—fill in the name you want—add

insert image description here
6. Start programming
insert image description here
insert image description here

2. Basic grammar of C language
1. Simple structure of C language
1), preprocessing instruction #include <stdio.h>
The standard input and output library in C language, the program cannot do any input and output without it. The symbol # indicates that this is a preprocessing directive, telling the compiler to perform some operations before compiling the source code. These directives are processed by the compiler during the preprocessing phase before the compilation process begins.
2), main() function
The main() function is the "main function". Every C program is made up of one or more functions, but every C program must have a main() function -- because every program always starts executing from this function. Almost all the work of the program is completed by each function. The function is the basic unit of the C program. A C language program consists of one or more functions, which must contain a main() function (and only one main( ) function).
3), program framework
insert image description here
4), printf() The function
printf() is an output function in the function library provided by the C compilation system.

2. Semicolon
Semicolon Each statement must end with a semicolon. It indicates the end of a logical entity
3, Note

insert image description here
4, Identifier
An identifier is the name used to identify a variable, function, or any other user-defined item. An identifier begins with the letters AZ or az or the underscore _ followed by zero or more letters, underscores, and digits (0-9). Punctuation characters such as @, $, and % are not allowed within C identifiers. C is a case-sensitive programming language. Thus, in C, Manpower and manpower are two different identifiers.

insert image description here
5. Keyword description
auto declares the automatic variable
break breaks out of the current cycle
case Switch statement branch
char Declare character variable or function return value type
const Define constant, if a variable is modified by const, then its value can no longer be changed
continue End the current cycle and start the next cycle
default " in the switch statement Other "branch
do The loop body of the loop statement
double declares the double-precision floating-point variable or function return value type
else the conditional statement negates the branch (used in conjunction with if)
enum declares the enumeration type
extern declares the variable or function in other files or this file Define
float in other places to declare floating-point variable or function return value type
for a loop statement
goto unconditional jump statement
if conditional statement
int declare integer variable or function
long declare long integer variable or function return value type
register declare register variable
return Subroutine return statement (with or without parameters)
short Declare a short integer variable or function
signed Declare a signed type variable or function
sizeof Calculate the data type or variable length (that is, the number of bytes occupied)
static Declare a static variable
struct Declare structure type
switch is used in switch statement
typedef is used to alias data type
unsigned declare unsigned type variable or function
union declares union type
void declares function with no return value or parameter, declares no type pointer
volatile declares variable can be implicitly changed during program execution
loop condition of while loop statement

Literature Citation
Baidu Encyclopedia
Blue Bridge Cloud Course
Cainiao Tutorial**

Guess you like

Origin blog.csdn.net/C222628/article/details/127230011