I've got an array of arrays of TCHAR
, where I store file extension.
TCHAR *extens[] = { L".*", L".txt", L".bat" };
In order to go through it, I'm calculating it's length.
int extCount = sizeof(extens) / sizeof(TCHAR);
But for some reason the extCount
's value is 2. I think the problem is because this is wrong calculation method, but then, how to count the number of elements ("words") in this array correctly?
UPD: I'am passing this array to function:
void func(TCHAR *path, TCHAR **names, TCHAR **extensions);
When i'am calculating this array lenght outside function it show correct number, but inside it always workis wrong (returns 2 or 1).
UPD2: I tried to redeclare array like this:
TCHAR *extens[] = { L".txt", L".bat", L".txt", NULL };
And now inside function i'am doing something like that:
TCHAR **p = extensions;
int extCount = 0;
while (*p != NULL)
{
extCount++;
*p++;
}
extCount = cnt;
wsprintf(temp, L"%d", cnt);
MessageBox(NULL, temp, temp, MB_OK);
It works, but looks like its not so effective, because of walking two arrays, isn't it?