C language work needs

1. Type

1.1. __int64

// 声明一个长度为1的64位整型数组, 并赋初值为0
__int64 G[1] = {
    
    0};

// 输出64为整型
printf("%I64d\n", G[0])

1.2. Address

int element_id = &param;
printf("%p", element_id);

2. Make C language library

2.1. Notes - Preprocessing Directives

  1. 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

  1. .h文件definition
#ifndef C_ADD_H
#define C_ADD_H

int add(int a, int b);

#endif
  1. .c文件Introduce the header file, and then implement
#include "add.h"

int add(int a, int b)
{
    
    
    return a + b;
}
  1. 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;
}

  1. My vscode uses a custom library file, which needs to be processed

4.1. In the set search bar, CODE RUNNER
insert image description here
change the line in 4.2 below to *.c
insert image description here

update…

Guess you like

Origin blog.csdn.net/weixin_46372074/article/details/129684792