C language work record
1. Type
1.1. __int64
// 声明一个长度为1的64位整型数组, 并赋初值为0
__int64 G[1] = {
0};
// 输出64为整型
printf("%I64d\n", G[0])
1.2. Address
int element_id = ¶m;
printf("%p", element_id);
2. Make C language library
2.1. Notes - Preprocessing Directives
- preprocessing directive
- #ifndef If not defined, keep segment 1
#ifndef 宏名
程序段1
#else
程序段2
#endif
- #ifdef If defined, keep block 1
#ifdef 宏名
程序段1
#else
程序段2
#endif
- Macro names must be globally unique
- #ifdef and #ifndef can only be followed by a macro name
example
.h文件
definition
#ifndef C_ADD_H
#define C_ADD_H
int add(int a, int b);
#endif
.c文件
Introduce the header file, and then implement
#include "add.h"
int add(int a, int b)
{
return a + b;
}
- Use custom library files
#include <stdio.h>
#include "add.h"
int main(void)
{
int a = 20;
int b = 10;
printf("%d+%d=%d\n", a, b, add(a, b));
return 0;
}
- My vscode uses a custom library file, which needs to be processed
4.1. In the set search bar, CODE RUNNER
change the line in 4.2 below to *.c
update…