Hi friends,
I'm new to c programming..........I need to know what is the use of double pointer and when will we use it?
Thanks
Ammu
Hi friends,
I'm new to c programming..........I need to know what is the use of double pointer and when will we use it?
Thanks
Ammu
Last edited by ammu; 11-10-2008 at 07:12 AM. Reason: error
Are you talking about something like this:
int **ptr;
??
The same reason as you'd have a pointer to integer vs. the integer itself.
A double pointer is simply an address of another pointer. The most common use is as an argument to a function where you need to be able to modify the pointer itself - so you need to have a pointer to the pointer, otherwise it can't be modified.
Another common case is two-dimensional arrays with dynamic sizing, in which case you'd have a pointer to a set of pointers to the actual data.
If you are asking about:
double *ptr;
then the question is "why do we need a pointer", and the above sort of explains some of that, but perhaps you would like to show us some code.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Well the first ever example you come across is this
int main ( int argc, char **argv )
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.