[comp.lang.c] What does char **ch mean?

orville@weyrich.UUCP (Orville R. Weyrich) (05/04/91)

I am studying for a C language exam, and a study guide I am using states 
that the declaration char **ch; is equivalent to char *ch;

I am having difficulty understanding this. My interpretation of the
declaration char **ch is that we have a pointer to a pointer to a char.
I think that this would be equivalent to the declaration char *ch[]
rather than what the study guide says. 

Am I missing something obvious?

Thanks,

orville.

--------------------------------------           ******************************
Orville R. Weyrich, Jr.                          Certified Systems Professional
Internet: orville%weyrich@uunet.uu.net             Weyrich Computer Consulting
Voice:    (602) 391-0821                         POB 5782, Scottsdale, AZ 85261
Fax:      (602) 391-0023                              (Yes! I'm available)
--------------------------------------           ******************************

toma@swsrv1.cirr.com (Tom Armistead) (05/05/91)

In article <1991May4.062007.3264@weyrich.UUCP> orville@weyrich.UUCP (Orville R. Weyrich) writes:
>I am studying for a C language exam, and a study guide I am using states 
>that the declaration char **ch; is equivalent to char *ch;
>
>I am having difficulty understanding this. My interpretation of the
>declaration char **ch is that we have a pointer to a pointer to a char.
>I think that this would be equivalent to the declaration char *ch[]
>rather than what the study guide says. 
>
>Am I missing something obvious?
>
>Thanks,
>
>orville.
>
>--------------------------------------           ******************************
>Orville R. Weyrich, Jr.                          Certified Systems Professional
>Internet: orville%weyrich@uunet.uu.net             Weyrich Computer Consulting
>Voice:    (602) 391-0821                         POB 5782, Scottsdale, AZ 85261
>Fax:      (602) 391-0023                              (Yes! I'm available)
>--------------------------------------           ******************************

Nope, your not missing anything.  Your 'study guide' is wrong!

Tom
-- 
Tom Armistead - Software Services - 2918 Dukeswood Dr. - Garland, Tx  75040
===========================================================================
toma@swsrv1.cirr.com                {egsner,letni,ozdaltx,void}!swsrv1!toma

lwb@pensoft.uucp (Lance Bledsoe) (05/07/91)

In article <1991May4.062007.3264@weyrich.UUCP> orville@weyrich.UUCP (Orville R. Weyrich) writes:
>I am studying for a C language exam, and a study guide I am using states 
>that the declaration char **ch; is equivalent to char *ch;
>
>I am having difficulty understanding this. My interpretation of the
>declaration char **ch is that we have a pointer to a pointer to a char.
>I think that this would be equivalent to the declaration char *ch[]
>rather than what the study guide says. 

You are correct.





-- 
Lance Bledsoe                       Off:    (512) 343-1111                 
Pencom Software, Inc.               Fax     (512) 343-9650                 
8716 Loop 360 N. Suite 300          UUCP:   cs.utexas.edu!pensoft!lwb      
Austin, Texas  78759                UUNET:  uunet!uudell!pensoft!lwb       

gwyn@smoke.brl.mil (Doug Gwyn) (05/07/91)

In article <1991May4.062007.3264@weyrich.UUCP> orville@weyrich.UUCP (Orville R. Weyrich) writes:
>I am studying for a C language exam, and a study guide I am using states 
>that the declaration char **ch; is equivalent to char *ch;

No, they're not at all equivalent.  They might not even have the same size.

>I am having difficulty understanding this. My interpretation of the
>declaration char **ch is that we have a pointer to a pointer to a char.

Correct.

>I think that this would be equivalent to the declaration char *ch[]
>rather than what the study guide says. 

The only place where char**ch and char*ch[] are equivalent is as a
declaration of a function parameter.

robc@cup.portal.com (Rob X Cowan) (05/07/91)

   char **ch and char *ch are not equivalent, but if the reference isn't
just a typo, perhaps the author meant that internally a pointer is a pointer
is a.. and that a pointer to pointer to a char is much like a pointer to a
char at the machine level.  Pure conjecture.

-Rob
robc@cup.portal.com