Hi everybody, Can you give me some exemples in what case we can use pointer in a program? Thank you. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Hi everybody, Can you give me some exemples in what case we can use pointer in a program? Thank you.

14th Aug 2016, 11:39 PM
Attitude
Attitude - avatar
4 Answers
+ 1
Functions can be given something called a return type, this specifies what type of thing the function will spit out when it finishes. The problem is that it's one thing that comes out and the only way I'm aware of for changing multiple variables via a function is by passing in pointers/references. Sometimes making a function for one thing at a time isn't the solution; or perhaps an efficient one anyway.
15th Aug 2016, 4:39 AM
Ahkrin
+ 1
Thank you a lot Ahkrin. I understand why we can use them now. If i have others questions i will come back here.
15th Aug 2016, 12:20 PM
Attitude
Attitude - avatar
0
If you need to affect two or more variables in a function you can pass pointers as arguments to the function as opposed to returning altered variables one at a time.
15th Aug 2016, 3:09 AM
Ahkrin
0
Thank you for your answer. You said: to return altered variables one at a time!! Can youexplain me much better please, i don't understand. Thx
15th Aug 2016, 3:15 AM
Attitude
Attitude - avatar