As Question says is there a way to read how many elements are in the char** array?
In following code print
function, should find count of elements in charpp
array without reading sizeofArray
variable.
#include <iostream>
using namespace std;
char** charpp;
void print(char** charpp){
cout << "Size: " << sizeof(&charpp) << "\r\n";
for(int i=0;i< sizeofArray;i++){
if (charpp[i]!=NULL)
cout << i << " : " << charpp[i] << "\r\n";
}
}
void main() {
int sizeofArray = 27;
charpp = new char*[sizeofArray];
for(int i = 0; i < sizeofArray; i++) {
charpp[i] = NULL;
}
charpp[1] = "test1";
charpp[5] = "test5";
print(charpp);
charpp? delete(charpp):0;
cin.get();
}
I'm Sorry if I am asking for impossible. I am mostly a C#, Java programmer and in both languages it is easy to find size of a string array.