What are the advantages of using pointers in a program?

Showing Answers 1 - 12 of 12 Answers

vivek kumar gaur

  • Sep 9th, 2005
 

The main advantages of using pointers are  
1.) Function cannot return more than one value. But when the same function can modify many pointer variables and function as if it is returning more than one variable.  
2.) In the case of arrays, we can decide the size of th array at runtime by allocating the necessary space.  
 
Coming to the disadvantages of pointers  
1.) If sufficient memory is not available during runtime for the storage of pointers, the program may crash (least possible) 
null

  Was this answer useful?  Yes

umesh ram sharma

  • Sep 3rd, 2006
 

the main advantage of pointer , you can play with o/s. you can hold the whole memory management. u can chage the content of IVT. u can write directly in the buffer of screen at address oxb8000000. like this many other advantage are their.

form the prog. view yes one can use dynamic memory allocation,as function passing argument, can find the address of any variable etc.

  Was this answer useful?  Yes

Manhongo Liberty

  • Nov 29th, 2006
 

Your answers are excellent.

  Was this answer useful?  Yes

thathireddy

  • Jan 27th, 2007
 

thanks your's answer is wellplease send me examples of pointers like functions using pointers,structures using pointers etc

  Was this answer useful?  Yes

The advantages of using pointers are:

1: you can work with the address of the variable
2: you can reference the variables in more different easiest ways....
    e.g  int a[10],*b;
                b=&a;
         if you want to refer a[5] you can refer it as a[5] or *(a+5) or *(5+a)
         this is a simple one....but in large programs it will make a difference.
3. if you want to access a variable quickly or efficiently with out wasting c.p.u time you have only 2 ways..
one is declare it as a register variable...
and other one is declare it with a pointer....
because a c.p.u has less registers in it ( approximately 6 i.e A,B,C,D,E,F,G,H),
when no register are freely available then you CAN DO THAT TASK WITH ONLY POINTERS....
4.by using pointers you can improve the c.p.u's throughput time
(throughput time refers to no of jobs done by the c.p.u in unit amount of time)....
   these are the advantages that can be acquired from pointers.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions