I recently read a document called "C language FAQ". I feel that there is a lot of knowledge in it, but it is easy to make a mistake! As the saying goes, "You can't do anything, you can't do anything as long as you have thousands of miles." Only after you have laid the foundation can you make a breakthrough. The Foundation is water, and fish cannot survive without it. The foundation is mountains, and trees cannot grow without it. The foundation is cloud, and it cannot survive heavy rain without it.
I have extracted important content from this document and want to share it with you!
In C language, there is a concept of "stream". streams can be divided into two types: Text streams (files) and binary streams (Files). Text streams are interpreted, it can contain a maximum of 255 characters. A binary stream is non-explanatory and can process one character at a time.
When programming in C language, we use the # include command to contain files of the type ". h". Can this command contain files of the type not ". h? The answer is yes. This is what I saw just now.
In C language, we often use macros. in programming, is macro better or function better? Generally, you should use macros to replace small and reusable code segments so that the program can run faster. When the task is complicated and requires multiple lines of code, or the smaller the program, the better the function should be used.
What is the difference between strcpy and memcpy? The strcpy () function can only copy strings, while the memcpy () function can copy any type of data. In C, you can use the itoa () function to convert Integers to strings, and the atoi () function to convert strings to integers.
In pointer operations, we need to distinguish between "NULL Pointer" and "void Pointer": the NULL pointer value is NULL and does not point to any object; void pointers are generally called generic pointers or generic pointers. They point to an object, but they do not belong to any type.
When can I use "Null Pointer "? 1) terminate indirect reference to the recursive data structure with a null pointer; 2) use a null pointer as the return value when the function call fails; 3) Use a null pointer as the warning value; when should I use the void pointer? You can use the void pointer when performing pure memory operations or passing a pointer to an undefined type.
Is NULL always defined as 0? NULL is defined as 0 or void * 0. These two values are almost the same. Is NULL always equal to 0? If it refers to "the result of comparison with 0 is equal", it is indeed equal to 0; if it refers to "the storage method is the same as the integer value 0", then the answer is "no ", NULL is not necessarily stored as an integer value of 0.
What does the conditional expression using a pointer for an if statement mean? When a pointer is used as a condition expression, the condition to be judged is actually "Whether the pointer is an empty Pointer". The two pointers cannot be added together.
In C language, the void keyword indicates that the function does not return values, and there is no need to add return statements. In some cases, a function may cause serious errors, if you want to exit the function immediately, you should add a return statement to skip the code that has not been executed in the function body.
What is the difference between exit () and return? The exit () function can exit the program and return the control to the operating system. The return statement can return the control from a function and return the control to the function that calls the function.
Is the subscript of an array always starting from 0? Yes; can I use the address of the first element behind the array? You can use the address of the first element after the array, but you cannot view the value in the address.
What is the difference between array_name and & array_name? The former is the pointer to the first element in the array, and the latter is the pointer to the entire array.
Why should we use standard library functions instead of writing functions by ourselves? Standard library functions have three advantages: accuracy, efficiency, and portability.
What is "local )"? A local environment is a description of the specific rules that the program should follow in a specific environment. It is very helpful for internationalization of the program.
Author: zhouzxi