In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
In order to solve this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
Pointer variable and address
Who is the variable for?
A variable is an abstract naming of a space.
A variable name is an alias for a piece of space that you abstract.
The pointer is the address. Point to an address.
Pointer and pointer variable
The pointer points to a block address. The pointer (address) is constant.
Pointer variables can be changed.
# include int main () {int I = 1; int * p = & I; printf ("I =% d\ n", I); printf ("& I =% p\ n", & I); printf ("p =% p\ n", p); printf ("& p =% p\ n", & p); printf ("* p =% d\ n", * p); / / Why not char* p = & I / / TYPE NAME = VALUE / / int* p = & I; / / int I = 1;}
Direct access indirect access
Take up memory space
All 8 bytes, in linux 64-bit.
Null pointer wild pointer null type
Int * I = NULL; pointer operation
Two pointers point to an array at the same time. + +, -, comparison, relationship, &, *
Pointer and one-dimensional array
What is the difference between an array name and a pointer?
An is an array name is a constant that represents an address.
The pointer is a variable.
Astatine +
Pendant +
# include int main () {int a [3] = {1pm 2pm 3}; int * p = a; int i; for (I = 0polii
< sizeof(a)/sizeof(*a); i++) { printf("%d %d %d %d \n",a[i],*(a+i),p[i],*(p+i)); // a[i] printf("%p %p %p %p \n",a+i, &a[i],p+i, p+i); // &a[i] } printf("\n");} 这里代码体现什么是指针常量什么是指针变量? #include int main(){ int a[3]; int i; int *p = a; for(i = 0;i < sizeof(a)/sizeof(*a); i++) { printf("%p ->% d\ n ", & a [I], a [I]);} for (I = 0 type name;-> int [3] * ptincincint main () {/ / Array pointer int a [2] [3] = {1m 2M 3M 5J 9}; int iJ; int * p = * a; int (* Q) [3] = a; / / printf ("% d\ n ", * a) Address of / / a [0] [0] / printf ("% d\ n", * * a); / / 1 # if 0 / / printf ("% d\ n", * p); / / Q / / int * p = * a; / / printf ("% d\ n", * p); / / Q / / int (* Q) [3] = aq1; / / printf ("% d\ n", * Q) / / 4 printf ("\ n"); for (I = 0
< 2; i++) { for(j = 0; j < 3; j++) { // printf("%p->% d\ n ", * (aplasi) + j endif * (* (aqumi) + j)); printf ("% p->% d\ n ", * (Qimi) + j));} printf ("\ n ");} # endif}
Pointer array:
# include # include # include / * int * arr [3];-> TYPE NAME;-> int * [3] arr;*/int main () {char * name [5] = {"english", "math", "cpp", "teacher", "computer"}; int iJournal j; for (I = 0; I
< 5; i++) { puts(name[i]); } for(i = 0; i < 5 ;i++) { int k = i; for(j = i+1;j < 5; j++) { if(strcmp(name[k],name[j]) >0) {k = j;} if (k! = I) {char * tmp = name [I]; name [I] = name [k]; name [k] = tmp; printf ("sorted:\ n"); exit (0);}
Pointers and functions
Function:
Echo $? / / displays the return value of the previous command
# include using namespace std;/* run this program using the console pauser or add your own getch, system ("pause") or input loop * / / * Definitions: int a [N] = {1meme 2meme 3rem 4m 5je 6}; int * p = a -> a * a [0] & a [3] p [I] p * p pendant 1-> int* int int int* * / void func1 (int* a line int n) void func1 (int* a line int n line int * b) {cout chinese);} return 0;}
Memory alignment problem
Addr/sizeof ()
Structural type-structure internal storage problem and function parameter transfer
Pave the way for the advanced linux in the back.
A student management system can be implemented.
Production and significance
Type description
Nested definition
Define variable
Occupied memory size
Function parameter transfer
Bit domain
Union name {data type member name 1; data type member name 2;}
Enumerated type
Enum name {member 1; member 2; member 3;} what is C language? C language is a process-oriented, abstract general programming language, which is widely used in low-level development. Using C language, low-level memory can be compiled and processed in a simple way.
This is the answer to the question about how to analyze the pointer, function, structure and common body. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.