C pointers referred chaos

A int // [. 3] [. 4] = {{66, 2,. 3,. 4}, {. 5,. 6,. 7,. 8}, {. 9, 10,. 11, 12 is}};
// read two-dimensional array int any element hint (*) a [. 4] I, J
// no copy function for the array, the array would be very wasteful of multiple cpu and memory
// for one-dimensional arrays may be used as a pointer to a variable parameter
// for two dimensional array can be an array of pointers int (*) [. 4]
// because there is no copy of the function is actually operating parameter modifications to the array itself
// reverse application bubble pointer algorithm (algorithm analysis may be a reference to an array section)
// output student achievement, there are four courses each student achievement, averaging the results, failing to extract
// ===================== function pointer = ====================
// after-defined functions. When compiling build system will designate as a function of a memory space, the first address of this memory space is the starting boundary function, which is a function pointer, the function name is actually a memory address, printf (function name), use vs2013 the disassembly functions, i.e., is a compilation of jmp goto C language, the reference game, picking chest, GOTO, send a request to the server, rhino picked antitank chariot void (* p) () = msg msg is another defined function, which is an indirect call function p (); this usage is often used to make hanging; MessageBoxA use of
the direct and indirect call statement calls the function pointer // pointers can only be assigned the function name (only goes to) ++ function pointers can not do - because there is no sense
// integrated example, to perform functions, function pointers are based on user input must explicitly return data type of the value parameter of type pointer must be consistent, Allied Dafa transfer, using the move function, this feature can also be used to hijack
// function returns a pointer ======================= ===================== =======
// define int * go () {return & b}, call * (Go ())
// array generates a random number, and returns the minimum value of the pointer, and modify the pointer in accordance with the minimum number of value, this basic technology in the string will be generous blossomed
// char str [40]; printf ( "% s", strcpy (str, " Chen Peichang like")); ----- implement a custom strcpy function, to realize the principle of the pointer control program window
// left value int a = 5, a value that is left, the pointer may be to the left of the variable value; pointer constant except PX = const * int
int A = 30, B =. 6;
the printf ( "a address% p, b addresses% P \ n-", & a, & B);
int * P;
Scanf ( "% X", & P); // input a hexadecimal integer, where the a, b address; after six input% x,% p input all digits
* P = 888;
the printf ( "% D \ n-", B);
System ( "PAUSE");
// null pointer can receive any type of pointer , malloc returns a pointer to the scene, the practical effect is void pointer express pointer
// void pointer to call attention, to be converted into the desired type of pointer
// Memset () for each byte of memory assignment #include <memory. h> memset (str, 'A ', 5 ) // num (5) = { 2,3,4,
// malloc (1024 * 1024 * 8 ) 8M memory allocation; void (*) p = malloc (1024 * 1024 * 20), directly to the memory address evaluation
// malloc () return void * in stdlib.h free (p) the address release memory; detect whether the memory allocation successful, whether the air
// malloc essence, for a large file, you can allocate a reasonable portion of the document placed memory space
// compiler to translate the code into machine instructions, not static allocation process big data, easy to waste memory, dynamic: you can apply at any time the program is running, release the memory
// the include <limits.h> void the p-* = malloc (UNIX_MAX)
// realloc re-allocate memory, with a copy of the original array to reallocate memory efficacy space realloc (p, newsize) realloc (allocated memory address of the newly allocated memory address), calloc (number of objects, the object number of bytes) try to define an array, and realloc
// malloc, realloc are allocated memory, but only the memory allocated realloc will do initialization
// warning: after the release of memory, the contents of the pointer does not change, then the reference pointer, will get junk data, program exceptions will happen, so soft Pieces of engineering specifications, pointer assignment should be empty! ! ! Memory can not be repeated release, do not release the address occupied not a pointer assignment is NULL, the problem can be circumvented repeatedly release the memory, and a pointer repeated references
// memory leaks: It is now known that the release of dynamic memory, does not mean that the pointer perish, the pointer changes value. So, if there is memory not released, but a pointer to point to this piece of memory has changed, or the demise of the event will be a memory leak, the leak will continue to lead to the collapse of the system, simulating a memory leak accident. Need to continue to run the application server, etc., especially this harm is staggering
// dangling pointer, the memory empty, the pointer is still pointing to the original piece of memory area, when accessed, print garbage data, solution-pointer with $ NULL
// getchar () will be treated as a character
// 32-bit maximum recognition 4G memory, I 2 32 billion bytes of each address represents a byte, a maximum power of 10 digits can only process 2 32 = 1024 2 is 4GB
value // pointer is stored in a 32-bit address, the size of a pointer is 4 bytes
// vs2013 can be selected by the configuration manager 64, for the preparation of 64-bit operating system, 64-bit addressing means stronger (if configured ARM, may require external devices and only the remote debugger)
// 64-bit analog 32: now the development of huge amounts of data, you need more memory for data processing, although the memory is 4G, but the cpu registers, the existing graphics card and other hardware also take up memory, the so-called 32 bit and 64-bit address is the number of bits. Server programming must use 64-bit. int, double occupancy and other 64-bit memory may be even greater, as determined by the compiler! Programming concept of memory and memory card hardware is different. 64 th power of 2, so that the compiler can manage massive amounts of memory, but also very fast memory handling capabilities.
// vs DEBUG mode: with debug information, the file is large, only to run up the code correctly
// vs RELEASE modes: optimized version, relatively slim, optimized code runs faster
// bug 80% concentrated in the program memory, C and requires the use of system memory interactive privileged instruction
_asm {

}
// debugging code may be viewed by registers, and memory information; the CPU and controller operation in two pieces (the value assigned address) 70% - C, 15% --- compilation, 15% --- C ++, instructions and data loaded into memory, the CPU is responsible for computing
// memory organized sequentially numbered, for loading data, the data memory is completed by the power supply; binary data stored in the memory, CPU execution is inseparable from the memory, the code region and a data area
// memory execution instruction code area ----
// ---- memory data to global and static data
// stack ---- temporary variables
,,
// memory composed of a series of little man , each small difference grid 1, grid small stores each 8 bits (i.e. a byte)
// address of the variable memory is actually abstract
variables --- // pointer variable pointer address stored exclusively, a variable, the stored value is a pointer
// ---- pointer points to a memory address, but this story is not complete, the pointer is the amount of memory, not just the address, and the data type
// pointer variable initialization necessary resistance, the system does not clear the binary data on the original address, once to visit , It may cause the program to crash, so be sure to initialize pointers before use. Of course vs2013 development IDE and other new security checks, but the vim and other tools not related to security
// prompted to stop working under windows tend to show your pointer out of line! Attempts to modify the operating system process memory variable
will be used pointer (plug-in) when the cross-process // modify variables, functions, changing external variables
// gcc vc array copies are no mechanisms
// the loop array, it is best to use a pointer loop index circulation may lead to cross-border;
// function return mechanism auto variable, the function is finished after the demise of the
int GET ()
{
A =. 3 int;
return A; // Zhexiang will return to the register, and the register address and the assignment can not be taken, if it took down, there is a copy of the mechanisms
}
// function is completed, the memory can be recovered, if just nobody uses memory, this memory still retain the original content, if someone used it, then there must be a garbled (code testing)
// return address stack area must not return address, static int a = 3
// the p-char * = "love cpc love xxd"; p string stored in the first address is not modified constant P = the while PX * char (* PX = '\ 0'!)
// arbitrary data types can be split into basic data types, returns a copy in a register, or, if the cache is not enough, will open section of memory (between the memory and the CPU) cache, becomes a virtual cache (also prohibit address) can, for example, the basic structure can be split into a variable into the cache
when the pointer // note data type int * p printf ( "% d \ n", * p) type --- --- analytically step
// declare an array of two ways structure (* p-> name)
* == structure ======================================== =========================== =========
data structure for storing a plurality of types of data structures of the invention

Guess you like

Origin www.cnblogs.com/saintdingspage/p/11966297.html