preparation

1. The overall idea of the course

  • The basic concept
  • Data types, operators, expressions
  • I/O topics
  • Process control
  • An array of
  • Pointer to the
  • function
  • Structural type
  • Management of dynamic memory
  • Debugging tool (DGB,make), debugging skills
  • Common library functions

2. Use of GCC and VIM

#indlude<stdio.h>
int main(a)
{
    printf("hello,world")
    exit(0)}Copy the code

3.C source files to executable programs

C source code –> preprocessing –> compilation –> assembly –> link –> executable

Pretreatment:

gcc -E hello.c 
Copy the code

The ‘#’ is pre-processed save the pre-processed file in an intermediate file in.i format

gcc -E hello.c >hello.i
Copy the code

Compile and translate into assembler files

gcc -S hello.i
Copy the code

Get a hello.s assembler file and compile it.

gcc -c hello.s
Copy the code

Get the target file hello.o

Package the resulting object file with the required environment library

gcc heollo.o -o hello
Copy the code

Get the final executable.

You can execute the following commands by skipping the previous steps

gcc hello.c -o hello
Copy the code

4. The vim configuration

Copy vimrc from /etc/vim to ~/. Vimrc

cp /etc/vim/vimrc  ~/.vimrc
Copy the code

Modify viM configuration:

The vim command is commonly used

5. Attention issues in programming

Display all of the warnings

gcc  hello.c -o hello  -Wall
Copy the code

Use of MAN manual

Format in man manual:

  • Name Name of the command and brief description of its functions
  • Synopsis: instructions, including optional 【 】 optional < will options > choose a {} a | b group
  • Description Description of the command
  • Options specifies the meaning of each item
  • Files Configuration file related to the command
  • bugs
  • Examples Examples
  • See also

Tips for use in man Manual:

  • Scroll backward one screen, b forward one screen
  • Flip a line: The enter key moves back a line, k moves forward a line
  • Looking backwards? Keyworkd looks forward
  • Exit the q