I have variable char ** string_list. Is there a function to obtain the number of "strings" in this list?
I have variable char ** string_list. Is there a function to obtain the number of "strings" in this list?
There is no list. What you have is a pointer to a pointer. If there is some kind of list involved, you need to keep track of its length with another variable, or determine it in some other way (e.g., traverse the list until you reach a special value that denotes the end of the list; a similiar idea can be found in the use of a null character and strlen()).
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Each row of a 2D structure, must be set with a size or an address. So the program must have some number that refers to the number of rows (number of strings), it's pointing to. It may be set with a #define ROWS 25 line of code, or by using a constant integer, perhaps like:
There is no function to tell you what that number might be, however.Code:for(i = 0; i < ROWS; i++) array[i] = malloc(COLS * sizeof(int));
Sorry for being misleading, I was going to put the word list in my post in quotes. I suppose I should have, or stuck to the vernacular used in the title.