How to determine the maximum index of a string array ?

Category: VC/MFC -> Foundation Classes Author: wm111212 Date: 2006-11-14 11:20:20
 
wm111212
2006-11-14 11:20:20
For example :   char   * array []   =   {" 1 ",   " 2 ",   " 3 "};
how to find the string array largest subscript value ( 3 ) it?
tjfangzhou
2006-11-14 11:26:55
sizeof (array) / sizeof (char *), but only on the array for such operations , if you carry out an assignment , such as
char **   p = array, this time then sizeof (p) is obtained by a 4 instead of 12 . So if you want to array as a parameter to a function , it can only put its size as another parameter passed into together .
panda7804
2006-11-14 11:44:29
int   len   =   sizeof (array) / sizeof (char);
zhaokun88
2006-11-14 12:01:34
int   len   =   strlen (array);