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/01 Report--
This article introduces the knowledge of "C language function return value and parameter transfer example analysis". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
One: parameter transfer
Parameter transfer is indispensable in the functions of C language, which can be used to pass values and pointers.
1. The form of passing a value: just pass a copy of the parameter value to the function, not the parameter ontology, such as:
Int test (int x pencil int y) {xfei2quoy; return x;} int main (void) {int adept% d, test (a); return 0;}
The running result is:
10,0
That is, the value-passing method can only pass the argument to the function, not change the argument itself.
two。 Pass pointer form: the address of the variable is passed directly to the function.
Such as:
Int a (int bjinint * c) {int item0; for (item0 witi 0)
Data is-> 2
Data is-> 4
Data is-> 6
Because the tuned function is within the scope of the parameter pointer, the ontology of the variable can be changed directly at this time.
Two: return value
The function returns a value in addition to passing parameters, which can return both the value of the variable and the address.
1. Return variable
Such as:
Int a (int b) {int iTun5; return 5;} int main (void) {int bread2; printf ("Data is->% d", a (b)); return 0;}
Running result
Data is-> 10
two。 Return address
Int * test (int b) {int iTuno BUF [4]; for
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.