当前位置:网站首页>C basic grammar
C basic grammar
2022-07-06 16:04:00 【Programming fish 66】
We have seen C The basic structure of the program , This will help us to understand C Other basic building blocks of language .
C The token (Token)
C The program consists of various tokens , Tokens can be keywords 、 identifier 、 Constant 、 A string value , Or a symbol . for example , Below C The statement includes five tokens :
printf("Hello, World! \n");The five tokens are :
printf
(
"Hello, World! \n"
)
;A semicolon ;
stay C In the program , Semicolons are statement terminators . in other words , Each statement must end with a semicolon . It shows the end of a logical entity .
for example , Here are two different statements :
printf("Hello, World! \n");
return 0;notes
C There are two ways to annotate a language :
// Single-line comments With // The first single line comment , This comment can take up a single line .
/* Single-line comments */
/*
Multiline comment
Multiline comment
Multiline comment
*//* */ Comments in this format can be one or more lines .
You cannot embed comments in comments , Comments cannot also appear in strings or character values .
identifier
C Identifiers are used to identify variables 、 function , Or any other user-defined project name . An identifier is in letters A-Z or a-z Or the underscore _ Start , Followed by zero or more letters 、 Underline and numbers (0-9).
C Punctuation characters... Are not allowed in identifiers , such as @、$ and %.C yes Case sensitive Programming language . therefore , stay C in ,Manpower and manpower Are two different identifiers . A few valid identifiers are listed below :
mohd zara abc move_name a_123 myname50 _temp j a23b9 retVal
keyword
The following table lists them C Reserved word in . These reserved words cannot be used as constant names 、 Variable name or other identifier name .
| keyword | explain |
|---|---|
| auto | Declare automatic variables |
| break | Jump out of current loop |
| case | Switch statement Branch |
| char | Declare a character variable or function return value type |
| const | Define constants , If a variable is const modification , Then its value can no longer be changed |
| continue | End the current cycle , Start next cycle |
| default | In the switch statement " Other " Branch |
| do | The body of a loop statement |
| double | Declare a double precision floating-point variable or function return value type |
| else | Conditional statement negates Branch ( And if Continuous use ) |
| enum | Declare enumeration type |
| extern | Declare that variables or functions are defined in other files or other locations in this file |
| float | Declare floating point variable or function return value type |
| for | A circular statement |
| goto | Jump statements without conditions |
| if | Conditional statements |
| int | Declare an integer variable or function |
| long | Declare long integer variable or function return value type |
| register | Declare register variables |
| return | Subroutine return statement ( With parameters , Or without parameters ) |
| short | Declare short integer variables or functions |
| signed | Declare a symbolic type variable or function |
| sizeof | Calculate data type or variable length ( That is, the number of bytes ) |
| static | Declare static variables |
| struct | Declare the struct type |
| switch | For switch statements |
| typedef | Used to alias data types |
| unsigned | Declare an unsigned type variable or function |
| union | Declare the common body type |
| void | Declares that the function returns no value or takes no arguments , Declare no type pointer |
| volatile | Explain that variables can be implicitly changed during program execution |
| while | The loop condition of a loop statement |
C99 New keyword
| _Bool | _Complex | _Imaginary | inline | restrict |
C11 New keyword
| _Alignas | _Alignof | _Atomic | _Generic | _Noreturn |
| _Static_assert | _Thread_local |
C Spaces in
Lines that contain only spaces , It's called a blank line , Maybe with comments ,C The compiler will completely ignore it .
stay C in , Spaces are used to describe spaces 、 tabs 、 Line breaks and comments . Spaces separate parts of a statement , Let the compiler recognize an element in a statement ( such as int) Where to end , Where does the next element start . therefore , In the following sentence :
int age;
ad locum ,int and age There must be at least one space character between ( It's usually a blank character ), So that the compiler can distinguish them . On the other hand , In the following sentence :
fruit = apples + oranges; // The total number of fruits obtained
fruit and =, perhaps = and apples The space character between is not required , But to enhance readability , You can add some spaces as needed .
resources & More in-depth readings :
Open the mysterious channel to get information, click the link to join the group chat 【C Language /C++ Programming learning base 】:828339809
边栏推荐
- [exercise-3] (UVA 442) matrix chain multiplication
- 数据在内存中的存储&载入内存,让程序运行起来
- [exercise 4-1] cake distribution
- [analysis of teacher Gao's software needs] collection of exercises and answers for level 20 cloud class
- HDU - 6024 Building Shops(女生赛)
- 滲透測試 ( 1 ) --- 必備 工具、導航
- 差分(一维,二维,三维) 蓝桥杯三体攻击
- 7-1 understand everything (20 points)
- Ball Dropping
- 最全编程语言在线 API 文档
猜你喜欢

Borg maze (bfs+ minimum spanning tree) (problem solving report)

STM32 learning record: LED light flashes (register version)

D - Function(HDU - 6546)女生赛

B - 代码派对(女生赛)
快速转 TypeScript 指南
![[analysis of teacher Gao's software needs] collection of exercises and answers for level 20 cloud class](/img/3b/dc43564a36f82e73826b08f39c935e.png)
[analysis of teacher Gao's software needs] collection of exercises and answers for level 20 cloud class

X-forwarded-for details, how to get the client IP

Record of force deduction and question brushing

渗透测试 ( 5 ) --- 扫描之王 nmap、渗透测试工具实战技巧合集

Essai de pénétration (1) - - outils nécessaires, navigation
随机推荐
Alice and Bob (2021 Niuke summer multi school training camp 1)
程序员的你,有哪些炫技的代码写法?
对iptables进行常规操作
Information security - Analysis of security orchestration automation and response (soar) technology
Record of force deduction and question brushing
Ball Dropping
Penetration test 2 --- XSS, CSRF, file upload, file inclusion, deserialization vulnerability
[exercise 4-1] cake distribution
Opencv learning log 32 edge extraction
Matlab comprehensive exercise: application in signal and system
区间和------离散化
Information security - security professional name | CVE | rce | POC | Vul | 0day
Opencv learning log 14 - count the number of coins in the picture (regardless of overlap)
Find 3-friendly Integers
TCP的三次握手与四次挥手
信息安全-威胁检测引擎-常见规则引擎底座性能比较
Path problem before dynamic planning
7-1 懂的都懂 (20 分)
想应聘程序员,您的简历就该这样写【精华总结】
[exercise-9] Zombie's Treasury test