Some grammatical concepts and functions common in C language

Common codes: 

  1. Program Entry: int main()The function is used to define the entry point of the program .

  2. Output: Use the function to print outputprintf() to the console .

  3. Input: Use scanf()the function to receive user input .

  4. Conditional judgment: Use if-elsethe statement to execute different code blocks according to the condition .

  5. Looping constructs: Use forloops, whileloops, or loops to implement repeated executiondo-while of code .

  6. Arrays: Define and manipulate one-dimensional or multidimensional arrays .

  7. String processing: Use string-related functions , such as strlen(), strcpy(), strcat()etc. for string processing.

specific function:

  1. Mathematics library functions: such as sqrt()(square root), pow()(exponentiation), sin(), cos(), tan()(trigonometric functions), etc.

  2. File operation functions: such as fopen()(open file), fscanf()(read input from file), fprintf()(write output to file), fclose()(close file), etc.

  3. Memory operation functions: such as malloc()(dynamic memory allocation), free()(release memory), memcpy()(memory copy), etc.

Complex concepts:

  1. Pointers: Understand the concept, usage and pointer operators *and& of pointers .

  2. Structures: Learn how to define and use structures , and how to access structure members .

  3. Dynamic memory allocation: Master the methods of dynamically allocating memory, such as using malloc(), calloc()and realloc().

  4. File pointers: understand the concept of file pointers, and learn how to open, read and write files .

Specific functions:

  1. Input validation: Write code to validate that user input is as expected, and handle cases where input is not valid.

  2. Sorting algorithm: Implement common sorting algorithms, such as bubble sort, insertion sort, selection sort, quick sort, etc.

  3. Search algorithm: implement common search algorithms, such as linear search, binary search, etc.

  4. Data structure: Understand and implement common data structures, such as linked list, queue, stack, etc.

  5. Multi-file programming: Learn how to split your code into multiple files and develop modularly in your application.

  6. Error Handling: Use error codes or exception handling mechanisms to handle error conditions that may arise in your program.


Some basic grammar rules of C language:

  1. Notes:

    • Single-line comments:  // start with , followed by the content of the comment. (C++ comment style)
    • Multi-line comments:  /* start with,  */ end with, and comment content in the middle. (C language comment style)
  2. Identifier:

    • Identifiers are used to name variables, functions, structures, etc. Identifiers consist of letters, numbers, and underscores , and cannot begin with a number.
    • Uppercase and lowercase letters are treated as different characters.
  3. keywords:

    • There are some reserved keywords in C language , such as  int, if, else, while etc. These keywords have special meanings and cannot be used as identifiers.
  4. Variable declaration and definition:

    • Before using a variable, you need to declare or define the variable and specify its data type.
    • When declaring a variable, you need to specify the data type and name of the variable, eg  int num;.
    • When defining a variable, in addition to specifying the data type and name of the variable, you can also assign an initial value to the variable , for example  int a= 0;.
  5. function:

    • Functions provide code encapsulation and reuse mechanisms.
    • A function consists of a function name, parameter list, return type, and function body, eg  int add(int a, int b) { return a + b; }.
  6. statement:

    • A program in C language consists of a series of statements, and each statement  ends with a semicolon ; .
    • Common statements include assignment statements, conditional statements, and loop statements .
  7. type of data:

    • There are basic data types in C language, such as integer types (such as  int, short), floating point types (such as  float, double), character types (such as  char), etc.
    • You can also use  typedef keywords to define custom data types.
  8. operator:

    • C language supports various operators, such as arithmetic operators, relational operators, logical operators, bitwise operators, etc.

at last

The above are some common grammatical concepts and functions in C language and some basic grammatical rules of C language . Hope to help you! ! !

Friends who have seen it, click three times with one button. Your support makes me more motivated to create and share. I hope it will always bring you surprises and gains.

Let's connect 3 times with one click!

 

Guess you like

Origin blog.csdn.net/weixin_57813136/article/details/132377146
Recommended