In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you an example analysis of C++ pointers, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to understand it!
Interview questions (pay attention to details)
Int main () {char* c [] = {"ENTER", "NEW", "POINT", "FIRST"}; char**cp [] = {% s\ n ", cpp [- 1] + 1); char***cpp = cp;printf ("% s\ n ", * * + + cpp); printf ("% s\ n ", *-- + + cpp+3); printf ("% s\ n ", * cpp [- 2] + 3); printf ("% s\ n ", cpp [- 1] [- 1] + 1); return 0;}
Do you get confused when you look at it? it doesn't matter. Let's draw a picture and talk about it.
Does this seem much more obvious, but it still needs careful analysis to make sure it is foolproof.
Print for the first time
Do + + p first and then dereference twice. As you can see in the picture below, we print POINT
Second printing
Start with + + CPP and then dereference-- change Clear1 to C, then dereference again, and finally + 3.
The printed result here is ER.
The third print
Let's start with the operation of CPP [- 2], which is equivalent to * (CPP-2), but also note that the value of our CPP has not changed here.
Here the direction of our (CPP-2) is represented by a black line, then dereferenced again, and finally + 3, which points to the ST in the figure.
So we print ST here.
The fourth print
CPP [- 1] is * (CPP-1) the CPP [- 1] [- 1] here is equivalent to * (* (CPP-1)-1) and finally + 1 points to EW.
Finally, we run the program to see the results.
The above is all the contents of this article "sample Analysis of C++ pointers". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.