Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!mcsun!unido!mikros!mwtech!martin From: martin@mwtech.UUCP (Martin Weitzel) Newsgroups: comp.lang.c Subject: Re: an elementary question concerning double indirection Keywords: double indirection, strtod Message-ID: <674@mwtech.UUCP> Date: 28 Feb 90 10:13:56 GMT References: <8146@hubcap.clemson.edu> <1458@amethyst.math.arizona.edu> Reply-To: martin@mwtech.UUCP (Martin Weitzel) Organization: MIKROS Systemware, Darmstadt/W-Germany Lines: 35 In article <8146@hubcap.clemson.edu> kaires@hubcap.clemson.edu (Robert G Kaires) writes: > this function has the syntax: > double strtod(const char *s, char **endptr); > >Why is endptr a pointer to a pointer (and not just a pointer)? >Unfortunately the description of double indirection is poorly explained >in my manuals, and no description of how to use this function is given. Yes, this is a constant source of trouble for novice C programmers. ******************************************************** NOTE: ** If you find a double pointer as formal argument ** ** in the description of some library function, this ** ** often means you have to supply the ADRESS of a ** ** (single) pointer variable! Furthermore pointers ** ** to C-struct-s as formal arguments often means you ** ** have to supply the adress of a struct-variable. ** ** Furthermore pointers to char (char *) often means, ** ** that an "array of char" (char foo[SIZE]) would be ** ** appropriate, when the function is called (%). ** ******************************************************** Please, do NOT take the above as general rule (eg there may well be situations where a double pointer formal argument needs a double pointer as actual parameter a.s.o.), but as a "warning light" which is switched on in your brains, if you read the manual! (%): If the library function *writes* to the location, the pointer points to, make sure "SIZE" is sufficient (and don't forget the terminating '\0'-Byte!). [the correct answer for the presented problem was allready given by another poster, I'll delete it] -- Martin Weitzel, email: martin@mwtech.UUCP, voice: 49-(0)6151-6 56 83