im trying to get length from my bidimensional char array
char **storelist;
i dont know how to do it.
ive tried
1 2 3 4
strlen(storelist);//error cannot converto char** to char*
sizeof(storelist)/sizeof(char**);//ever return at 1
for(unsignedint i=0;storelist[i]!=NULL;i++)continue;//wrong result
for(unsignedint i=0;strlen(storelist[i]);i++)continue;//wrong result
this char **storelist; is not a definition of two-dimensional array. I suspect that it is a pointer to an arrray of pointers. Then you need know what is the size of the array of pointers.
Vlad is correct, it is a pointer, which when initialized, becomes an array of pointers. While the pointers in the array are sequential in memory, their value (the address they point to) is not.
If Line 3 is giving you the wrong answer, then I suspect you want more than the amount of char* that you have created. I assume you want the length of all of the c-strings combined.
If this is the case, then you need a little more to that for loop:
1 2 3
int total = 0;
for(unsignedint i=0;storelist[i]!=NULL;i++)
total += strlen(storelist[i]);
hm
i want know how much strings the pointer have
eg:
char *storelist[]={"Grass","Forniture","Tools"};
this is a pre-defined array,then i know the length is 3
but when there are so much values kind ~200 values in the array pointer, how to get the number of char * of easy way?