pointers | Sololearn: Learn to code for FREE!

0

pointers

Can someone explain pointers simply? I have checked a lot of videos but couldn't understand

10/22/2021 10:23:52 AM

ultra dead meme

10 Answers

New Answer

+7

Explaining pointers simply is not possible if you want to understand pointers. Simply stating that pointers are addresses is a gross over simplification. That's like saying maths is just numbers. I have two books on my bookshelf about pointers. Yes, entire books have been written about pointers. C++ goes a long way to reduce the number of times you need to use pointers. The use of string classes, container classes, iterators, and pass by reference can all but eliminate the use of pointers in most common usage situations. However, it is still important to understand pointers since a lot of APIs and existing code use them. There are also cases where pointers are the preferred solution. Rather than attempting to learn pointers as an abstract subject it is preferable to have actual usage cases and good examples. https://www.oreilly.com/library/view/understanding-and-using/9781449344535/ https://www.oreilly.com/library/view/practical-c-programming/0596004192/ch20.html https://www.oreilly.com/library/view/learning-path-beginning/9781491961001/video243565.html https://www.oreilly.com/library/view/practical-c/0789721449/ch14.html

+3

Pointers are little tricky you need to do practice search geeksforgeeks pointers topic this site will help you

+3

Printers are just another kind of variables, which can store address of another variable and can change value of that variable permanently. When we use pointer as parameters in functions then it's called Call by Reference. Asterisk (*) is used to define a pointer. You need to use adress of operator (&) to store address of another variable. For example: int x=10; int *ptr = &x; *ptr = 20; printf ("%d ",x); //output 20. printf ("%d ",*ptr); //also 20

+3

ultra dead meme use @ and type name to call a specific person. @ here is like a pointer pointing to the name of the person.

+1

ultra dead mem, Rupali's example is valid code but somewhat contrived. It simply demonstrates the principles but there is no point in doing it other than to demonstrate the principles. Typically pointers are used when values need to be updated by a function. Since C and C++ typically pass primitives by value. Any changes to the value in a function do not effect the value outside of the function. In order to effect the original variable it has to be passed using a pointer. A more important use of pointers is to make passing data structures to functions more efficient. Instead of copying the entire structure we simply pass the pointer. This saves both time and stack space. There are many other uses of pointers.

+1

Martin Taylor really?!!! What do those two books say about pointers? I think a maximum of ten pages is enough to fully explain them.

+1

Pointers use to access memory locations, It is an address of a memory location,

0

Rupali but what will I do with that? Why is it important

0

Pointer is just a variable like other variables but it is used to store address of other variables. So, you will be able to access that variable using it's address

0

How do I reply to a specific person? Martin😂