|
From: bokiteam on 3 Mar 2006 03:11 Hi All, Here is the declaration I can't understand: APattern_t * * gStatePatterns ; /*the array of pointers to the state patterns */ // this is pointer's pointer? why we need this ? Here is the APattern_t's define: typedef struct APatternTag { ..... ...... }APattern_t ; BR/ Boki.
From: Jim Langston on 3 Mar 2006 03:40 <bokiteam(a)ms21.hinet.net> wrote in message news:1141373509.420868.190630(a)p10g2000cwp.googlegroups.com... > Hi All, > > Here is the declaration I can't understand: > > APattern_t * * gStatePatterns ; /*the array of pointers to the > state patterns */ > > // this is pointer's pointer? why we need this ? > > Here is the APattern_t's define: > > typedef struct APatternTag > { > > .... > ..... > > }APattern_t ; > > BR/ > Boki. A pointer to a pointer is typically used as a pointer to an array of pointers. A very good example of this is the typical definition of main: int main( int argc, char **argv ) { } argv is used as an array of character pointers. So argv[0] would be a pointer to an array of characters (c style string, null terminated character array). argv[1] would be another pointer to an array of characters. Look at how gStatePatters and you'll probably find it being treated as an array of pointers.
From: bokiteam on 3 Mar 2006 03:43 Got it! Thank you very much! BR/ Boki. Jim Langston wrote: > <bokiteam(a)ms21.hinet.net> wrote in message > news:1141373509.420868.190630(a)p10g2000cwp.googlegroups.com... > > Hi All, > > > > Here is the declaration I can't understand: > > > > APattern_t * * gStatePatterns ; /*the array of pointers to the > > state patterns */ > > > > // this is pointer's pointer? why we need this ? > > > > Here is the APattern_t's define: > > > > typedef struct APatternTag > > { > > > > .... > > ..... > > > > }APattern_t ; > > > > BR/ > > Boki. > > A pointer to a pointer is typically used as a pointer to an array of > pointers. A very good example of this is the typical definition of main: > > int main( int argc, char **argv ) > { > } > > argv is used as an array of character pointers. So argv[0] would be a > pointer to an array of characters (c style string, null terminated character > array). argv[1] would be another pointer to an array of characters. > > Look at how gStatePatters and you'll probably find it being treated as an > array of pointers.
|
Pages: 1 Prev: Help with vectors of derived class pointers Next: Create loop to count words in a file |