Question on pointer-to-pointer-to-pointer 
Author Message
 Question on pointer-to-pointer-to-pointer


Quote:
>Hi,
>Below is one of the question asked by my student about pointer-to-pointer in
>C - with a specific example on strtod() function. Can anyone help me explain
>this to my student. Especially on the important of pointer-to-pointer.

>Thanks

>Bahari Belaton

>=======================================================================
>Dear All,
>     I hope you can enlighthen me a bit.
>Query 1:
>     According to Deitel, the function prototype for strtod() is:-
>     double strtod(const char *nPtr, char **endPtr) and the function call is
>as follows :-
>     double d;
>     char *string = "51.2% are admitted";
>     char *stringPtr;

>     d = strtod(string, &stringPtr);

>The book says that &stringPtr is assigned the location of the first character
>after the converted value. How does the function do that?

Remember, a function cannot modify an argument unless the argument is a pointer
to the object to be modified.  Thus if you want the strtod() function to
set a pointer to the next character, you must supply a pointer to the
memory location to contain the result (a char *).  Of course &(char *) is
a char **.

Quote:

>I'm still confused with **endPtr. Why the **endPtr(pointer to a
>pointer) is used?(What is the significance of using a double pointer? Why
>not just *endPtr since the function assigned the address of first
>character of the string to &stringPtr. (what about***endPtr?
>How many pointers to pointer can we used?)

The number of levels of indirection is usually limited by human understanding
before it is limited by the compiler.  Most programs do not use more than
3 levels of indirection.

Quote:

>Thank you very much.
>Your student,

>=================================




Sat, 11 Jul 1998 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Dereferencing f-pointers, arrays of f-pointers, pointers to f-pointers

2. memory leak: pointer->pointer->pointer->struct

3. Pointer of Pointers was Pointer of arrays...

4. memory block containing pointers, aka pointer to pointer i believe

5. pointers pointers pointers!!!

6. memory Leak: pointer->pointer->pointer->struct

7. Pointer Functions and Pointers to Pointer Functions

8. Pointer to Pointer to Pointer....

9. How to use (pointer to function), and function and pointer to (pointer to function)

10. double pointer (or pointer to pointer)

11. Pointers: return of pointer to array of pointers to main

12. Why Wont This Compile Right--Pointer to Pointer to Pointer to Float

 

 
Powered by phpBB® Forum Software