In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains why there are no references in C language and there are only pointers. Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn why there are no references in C language and there are only pointers.
What is a citation?
To put it bluntly, a reference is to create a new name for an existing variable, and if the program does something about the reference alias, it is actually a change to the original target.
C + + reference instance
# include # include void exchange (int & x, int & y) {int t; t = x; x = y; y = t;} int main () {int awagh b; scanf ("% d% d", & a, & b); exchange (ameme b); printf ("% d% d\ n", amaine b); getchar (); return 0;}
Program output
12 34 34 12-Process exited after 3.121 seconds with return value 0 Please press any key to continue. . .
What is the C language?
The C language is an ever-changing pointer, and when references appear in C++, it makes programming very friendly. If you look at the operation above, it looks very clear.
But we can also use pointers to do the above.
Instance code
12 34 34 12-Process exited after 3.121 seconds with return value 0 Please press any key to continue. . .
Program output
12 56 56 12-Process exited after 2.477 seconds with return value 0 Please press any key to continue. . .
Leave a topic for discussion
Discuss what the following program outputs?
# include # include void exchange (int * x, int * y) {int * t = x; * x = * y; * y = * t;} int main () {int a, b); scanf ("% d% d", & a, & b); exchange (& a, & b); printf ("% d% d\ n", aMagna b); getchar (); return 0 At this point, I believe you have a deeper understanding of why there is no reference to the C language and only pointers. You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.