search
Login

Categories


C Books Guide and List
C++ Books Guide and List
Best Java Books

3.8k questions

4k answers

117 comments

10.7k users

0 votes
85 views
asked Expert 13.2k points 26 40 57

1 Answer

0 votes
Pointers are special variables which store address of some other variables.

Syntax: datatype *ptr;

Here * indicates that ptr is a pointer variable which represents value stored at a particular address.

Example: int *p;

'p' is a pointer variable pointing to address location where an integer type is stored.

Advantages:

1. Pointers allow us to pass values to functions using call by reference. This is useful when large

sized arrays are passed as arguments to functions. A function can return more than one value by using call by reference.

2. Dynamic allocation of memory is possible with the help of pointers.

3. We can resize data structures. For instance, if an array's memory is fixed, it cannot be resized.

But in case of an array whose memory is created out of malloc can be resized.

4. Pointers point to physical memory and allow quicker access to data.
answered Guru 39.1k points 10 21 32

Related questions

0 votes
1 answer 457 views
0 votes
1 answer 105 views
105 views
asked carlton Sr Member 4k points 5 11 21
0 votes
1 answer 21 views
0 votes
1 answer 18 views
18 views
asked smith Geek 15.3k points 14 39 58
0 votes
1 answer 25 views
...