Tuesday, July 14, 2009

What is the necessity of pointers in C language explicitly or implicitly?

interview question asked in infosys and can't we have C language without the pointers??

What is the necessity of pointers in C language explicitly or implicitly?
Pointers are needed for:





Reference parameters in functions (call by reference)


For functions with variable arguments (like printf)


Dynamic data structures (like trees, lists and dynamically allocated arrays)


As function pointers (callbacks) used mainly in libraries for code reuse (see qsort function)





For system programing (low level I/O).





Without pointers C would be something like the primitive basics used in home computers.





There are alternatives to pointers called references, but those are only used in modern langauges like C# or Java.
Reply:Possibility of both are exist because you can create reference of pointer as void (pointer i.e., void *) then explicitly give the address of any type...





in contrast of implicitly you can create any type data pointer and which will hold the address of related type...





so it depends on your need. I hope it will help full for you.





if any question in more precise way..





bye

plum

No comments:

Post a Comment