当前位置:网站首页>C language -- legal identifier and integer
C language -- legal identifier and integer
2022-06-26 16:41:00 【D_ eretay】
Let's first introduce , Start learning c What is the first header file that the language encounters
The header file
Also known as toolbox
Provide a series of methods ( Tools )
#include <stdio.h>
#include "stdio.h"<>: Search directly in the system directory If it is not found, an error will be reported directly
" ": First, search under the current directory Can't find it. Look it up in the system directory If it is not found, an error will be reported directly
summary : Generally, in order to improve efficiency, I will use " " instead of <>
In general , System file usage <> Custom files are usually placed in the current directory So use " "
Constant
Constants usually have the following
integer constants such as :1、100、999、6366
Real constant such as :1.0、3.14
character constants such as :'A'、'a'、'1'
String constant such as :"aA1"
Symbolic constant utilize #define To define constants
address constant
Variable
Variable : It represents a with a name , A storage unit with specific properties . Can be used to store data ( The value of the variable )
Variables must be defined before using . The naming of variables must conform to the specification
Naming specification
By digital , Letter , Underline composition
Cannot start with a number ( In general, you will not start with an underscore )
It can't be a keyword
Be careful :
Case sensitive
Nomenclature Naming habits
Write the name according to its meaning
give an example :
// We want to describe the health of a character in the game ( data ==> Stored in memory )
// This memory Let's give him a name ==> Variable name
Example :
hp xueliang a b abc hp HP
a1 b2_
Error model :
123 1aLegal floating point numbers
Decimals and exponents
decimal
Index ( Scientific enumeration : n*10^m eE) Such as :3.14e3
char And octal
The following is an example through code
Numbers and numeric characters
'\0' Terminator ( character string ) // A: -128 -- 127 B: 0 -- 255 // 0 -- 255 ==> 0 -- 0377 char ch; ch = '\0'; printf("ch = 0%o\n", ch); ch = '\377'; printf("ch = 0%o\n", ch); // 1 Why are there eight more 7 // 2 If more than 377 What will happen? // Improve the overall shape // char Type in operation Will be promoted to int type // After the operation Will revert to the original typetoggle case
// 'A': 65 // 'a': 97 // '0': 48 // 1 '0'==>0 char ch = '0'; ch = ch - ('0' - 0);// Subtract the difference printf(" Numbers : %d\n",ch); // 0 // 2 0==>'0' // 'A' ==> 'a' char ch1 = 'A'; ch1 = ch1 + ('a'-'A'); printf("%c\n", ch1); // a
sizeof()
// Application :sizeof() Operator
/*
character : ''
character string : "" "" "a" "123"
*/
printf("%d\n", sizeof("")); // "\0"
printf("%d\n", sizeof("a")); // "a\0"
printf("%d\n", sizeof("123")); // "123\0"
printf("%d\n", sizeof("ab12\\1234\0ab")); //
printf("%d\n", sizeof("\1a")); //
printf("%d\n", sizeof("\128")); // 3effect : Count bytes , seek () The objects inside occupy a few bytes in memory
In general :
position = byte
A byte is eight bits
short sh = 0;
printf("%d\n", sizeof(sh));
printf("%d\n", sizeof(short));Value range
Make small value ---- Maximum
Unsigned : 0-65535 (65536)
The signed : -32768--0--32767 (65536)
Data overflow
The size of the data exceeds the range that the current type can represent
Use time :
It will overflow when the data is stored
Processing mode :( Automatic adjustment )
The data is too big : Subtract... From the data n Range sizes
The data is too small : Add... To the data n Range sizes
Range size : The number of data that the current type can represent
integer
data type
short: Short int: integer long: Long integer long long: long long
Is a type of data type , Include :
short int long long long
// Defined a int Variable of type
// Name the variable hp
// Initialize the variable to 100
int hp = 100;
// Defined a int Variable of type
// Name the variable num
int num;
// to num The assignment is 0
num = 0;
Be careful :
1 Integer defaults to int type
2 Between integers , The result is still an integer
// Output statement
// 1 Simple
printf("hello world!\n");
// 2 A little difficult
printf("num The value of is :%d\n", num);
// 3 It's a little difficult
printf("hp = %d, num = %d\n", hp, num);
// Output statement
// 1 Simple
printf("hello world!\n");
// 2 A little difficult
printf("num The value of is :%d\n", num);
// 3 It's a little difficult
printf("hp = %d, num = %d\n", hp, num);
#include <stdio.h>
int main()
{
short sh = 1;
int num = 10;
long n = 100;
long long m = 1000;
/*
short: Short
int: integer
long: Long integer
long long: long long
short int sh = 1;
int num = 10;
long int n = 100;
long long int m = 1000;
*/
/*
They are all integers Can be used to define integer variables
that How should we choose the type ?
*/
// The phenomenon :
short s = 0;
printf("s = %d\n", s);
s = 100;
printf("s = %d\n", s);
s = 32768;
printf("s = %d\n", s);
s = 32769;
printf("s = %d\n", s);
// analysis :
// The data has changed ==> Maybe the data is too big
// knowledge :
// Data overflow (1 Range 2 overflow )
return 0;
}Process oriented
First c Languages usually write programs that are process oriented , The following describes its process
technological process
The process of program execution : From the top down , Sentence by sentence execution ; Encountered a specific syntax structure , Execute according to the grammar rules
entrance 、 exit
// Every project There is only one entrance
// The main function Entry function main function
int main()
{
// Code valid area
return 0;
// Code invalid area
}
perhaps
void main()
{
} notes
// Single-line comments
/*
Multiline comment
1
2
3
....
*/Hexadecimal conversion
Measurement method ( How many into one It's a decimal )
Decimal system : full 10 Jin Yi
Hexadecimal : full 16 Jin Yi
Binary and octal representations
Binary system :0b 0B
octal :0
A number on a digit
Express ( features )
give an example
Binary system 0 1 Only 0 and 1 10100101
octal 0 1 2 3 4 5 6 7 0 start 01457
Decimal system 0 1 2 3 4 5 6 7 8 9 No special requirements 666
Hexadecimal
0x start 0 1 2 3 4 5 6 7 8 9 a b c d e f 0x12af
0X start 0 1 2 3 4 5 6 7 8 9 A B C D E F 0X34CD
Welfare part :
About vs2013 Press F5 Unable to jump out of the console
The first way
#include <Windows.h> // Be sure to add this header file
void main()
{
system("pause"); // Add this code at the end to solve
}
The second way
getchar(); // Add this code at the end of the function 边栏推荐
- 基於Kubebuilder開發Operator(入門使用)
- 精致妆容成露营“软实力”,唯品会户外美妆护肤产品销量激增
- 我把它当副业月入3万多,新手月入过万的干货分享!
- 108. 简易聊天室11:实现客户端群聊
- Supplement the short board - Open Source im project openim about initialization / login / friend interface document introduction
- What is the process of switching C # read / write files from user mode to kernel mode?
- 若依微服务特殊字符串被过滤的解决办法
- Oilfield exploration problems
- 架构实战营毕业设计
- In a bad mood, I just write code like this
猜你喜欢
Scala 基础 (二):变量和数据类型

Knowing these commands allows you to master shell's own tools

r329(MAIX-II-A(M2A)资料汇总

牛客编程题--必刷101之动态规划(一文彻底了解动态规划)

Science | giant bacteria found in mangroves challenge the traditional concept of nuclear free membrane

Big talk Domain Driven Design -- presentation layer and others
![[Li Kou brush questions] 11 Container holding the most water //42 Rain water connection](/img/45/1e712300ea655856762394fba09066.png)
[Li Kou brush questions] 11 Container holding the most water //42 Rain water connection

Cuckoo filter for Chang'an chain transaction

Net based on girdview control to delete and edit row data
Scala Basics (II): variables and data types
随机推荐
Scala Basics (II): variables and data types
Niuke programming problem -- dynamic programming of must brush 101 (a thorough understanding of dynamic programming)
Research on natural transition dubbing processing scheme based on MATLAB
mha 切换(操作流程建议)
Gui+sqlserver examination system
对话长安马自达高层,全新产品将在Q4发布,空间与智能领跑日系
Keepalived 实现 Redis AutoFailover (RedisHA)
Net based on girdview control to delete and edit row data
Redis 迁移(操作流程建议)1
Least squares system identification class II: recursive least squares
R language plotly visualization: Violin graph, multi category variable violin graph, grouped violin graph, split grouped violin graph, two groups of data in each violin graph, each group accounts for
内存分区模型
Detailed explanation of cookies and sessions
What does the inner structure of the neural network "alchemy furnace" look like? An interpretation of the thesis by the doctor of Oxford University
【毕业季】致毕业生的一句话:天高任鸟飞,海阔凭鱼跃
day10每日3题(1):逐步求和得到正数的最小值
请指教同花顺软件究竟是什么?网上开户是否安全么?
What is the process of switching C # read / write files from user mode to kernel mode?
When a programmer is disturbed 10 times a day, the consequences are amazing!
JUnit unit test