What the role of pointer in c++and c? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What the role of pointer in c++and c?

2nd May 2020, 3:15 AM
Gaurav
Gaurav - avatar
3 Answers
+ 2
Another useful case for pointers is when passing around pointer references to big data structures. You don't want to pass big structs to functions by value which are implicitly copied, because that is slow and can blow up the stack. Instead you pass the pointer around which holds the address of the structure, which is very useful. Except in C++ you'd probably use a reference '&' and not a pointer.
2nd May 2020, 6:25 AM
Damyian G
Damyian G - avatar
+ 1
pointers are very useful as they are the variables which can store the other variables(address).Simply,they can point or store the adresses of functions,arrays,strings,another variable.so,all you have to do is u can assign them to whichever variable u want.They actually make coding feasible and easy.
2nd May 2020, 9:05 AM
Lakshmi Priya Althuru
Lakshmi Priya Althuru - avatar
+ 1
Pointer is a special variable which holds the address of another variable ,so that it can point to the particular address during the execution, which makes the program more comfortable to perform. We use indirection operator('&') with pointers. Every pointer occupies 4 bytes of memory irrespective of its datatypes.
5th May 2020, 12:18 PM
Patnam Sai Prasanna Reddy