C Coding Question

Guy Harris guy at sun.uucp
Mon Aug 11 09:20:59 AEST 1986

> Here's the question:  Should help and description be declared char *help[]
> or char **help?

Since you've already shown a declaration for them, and since you've done it
correctly, I'm not sure why you're asking.  Since "help" would be an array
of pointers to characters, which is in no way equivalent to a pointer to a
pointer to a character, you obviously declare it as such - "char *help[]".
Try it the other way ('char **help = { "foo", "bar", ... };') and the
compiler will let you know, in no uncertain terms, that it's not correct.

> Should say() be declared void, or is there some sort of error checking I
> should implement?

That depends on whether you can do anything useful if you detect an error.
For example, it's rarely useful to check for errors on an "fprintf" to
"stderr" - if it fails, what can you do, print a message to "stderr"
indicating you can't print a message to "stderr"?  (The VMS routine that
prints error messages never returns a failure indication, probably for much
the same reason.)  Even if you have something useful to do on an error, you
may want to do it entirely within "say".
	Guy Harris
	{ihnp4, decvax, seismo, decwrl, ...}!sun!guy
	guy at sun.com (or guy at sun.arpa)

More information about the Comp.lang.c mailing list