After graduation for several years, I have been using C at work, but the more I use it, the more I feel that I have mastered it too superficial. I will repeat the basic knowledge in my spare time.
Time: 2010-12-09
Topic: start programming in
You should have seen this in many books:
1. the return value of the function cannot be a local variable;
2. The local variables in the function are automatically destroyed after the function is called, because the local variables are stored in
1. Basic explanation
Extern can be placed before a variable or function to indicate that the definition of a variable or function is in another file, prompting the compiler to find its definition in other modules when it encounters this variable
I. Introduction:
1. File Inclusion:
ProgramAll the functions, types, and macros used in the file include:
# Include "python. H"
In this example, the standard header file and are implicitly included (if available)
Note: Python may have some
Today, I saw such a problem on the Internet: "If malloc has a string of memory, then it changes the size of the string and asks if some memory is not released ." I did not think about this issue carefully before.
Of course, I think it will
Overview
C LanguageThere is a parameter with an uncertain length, such :\"... \ ", Which is mainly used in functions with uncertain number of parameters. The most common example is the printf function.
Prototype:
IntPrintf (Const Char* Format [
2. What is a pointer?
It's not easy to understand! Many of us who are new to pointer should feel this way. I often think about it. Why? In fact, there are pointers everywhere in life. We also use it everywhere. With it, our life is more convenient.
1. array elements
See the following:Code
IntI, a [] = {3,4,5,6,7,3,7,4,4,6};For(I =0; I 9; I ++){Printf ("% d", a [I]);}
Obviously, it shows the element values of array.
We can also access the element as follows:
IntI, a [] = {3,4,5,6,7,3,7,
# Include Int Factorial ( Int N){ Int I = 0 ; Int Sum = 1 ; Int Array [] = { 0 }; For (I = N; I> = 1 ; I --){Sum = sum * I;} Return SUM;} Int Arrangement ( Int N, Int M){ Int Result = 0 ; If (M> N){Printf ( " Your input is incorrect. The number
Pointer to another pointer
I. pointer concept:As early as in the second part of this series, I have elaborated on the essence of pointers. Today, we need to learn a pointer that points to another pointer address. Let's review the pointer concept
The last time I talked about some interesting interview questions, today we will look at some interview questions about pointers and sizeof:
Below are some interview questions I have seen
5. Brief IntroductionChar * const P;Char const *
An integer array is defined as follows:Int A [] = {1, 2, 3, 4}; if it is simply written as a; // The Name Of The array identifier, it indicates the memory address of the first element of the array,; it is equivalent to & A [0]. Its type is a pointer
Library functions are high-level and fully run in the user spaceProgramProvides a more convenient interface for calling the system that actually completes the actual transaction in the background.System calls run in kernel mode and are provided by
I. cProgramBucket Layout
C Programs are always composed of the following parts:
1)Body section-- Machine commands executed by the CPU; a program has only one copy; read-only, to prevent the program from modifying its own commands due to
Basic explanation
This section describes a series of common programming problems caused by the following two features of the C compiler.
Compile C files separately:CProgramIt is usually composed of several small programs (. c files). The
Write a good C language. A beautiful macro definition is very important. Using a macro definition can prevent errors, improve portability, readability, and convenience. The following lists some macro definitions commonly used in mature software .....
Basic explanation
1. The essence of a pointer is an address-related composite type. Its value isData storage location (address);An array is essentially a series of variables..
2. the array name corresponds to (rather than pointing to) a piece of
1. Memory Allocation Method
There are three memory allocation methods:
(1)From staticStorageRegion allocation. InnerProgramThe program has been allocated during compilation, and the program exists throughout the runtime. For example, global
1. Basic explanationTypedef is a key word in C language. It defines a new name for a data type. The data types here include internal data types (INT, Char, etc.) and Custom Data Types (struct, etc ).In programming, typedef is generally used for two
This is a program of the bubble method:# IncludeVoid sort (int array [], int size){Int I, j, temp;/* The following uses adjacent comparisons to place large numbers on top ;*/For (I = 0; IFor (j = I + 1; jIf (array [I]> array [j]){Temp = array
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service