N
Nobody
excuse the "windows" code below, but this is a C++ question... or maybe a C.
Anyways, I want a function where I can pass in an array of strings (variable
count, variable size), so I defined this:
void Test(LPCTSTR* ppsz, int nCount)
{
for (int nIndex = 0; nIndex < nCount; nIndex++)
TRACE(".%s.\n", ppsz[nIndex]);
}
and call it like:
TCHAR sz[5][32] =
{
"United States",
"Canada",
"Mexico",
"United Kingdom",
"South America"
};
Test((LPCTSTR*)&sz, 5);
The Test function crashes no matter what I do (various indirection styles,
etc) even on nIndex = 0?!?!?!
How can I do this? Would the Test function need to know the 32 to get the
next pointer...
Seems like what I want to do is pass in an array of pointers?
Any simple way to do that similar to the above? without new and delete and
so forth and not using a string list class?
this is for an API that I am writing, so I want minimal dependencies and
minimum chance for a developer to pass me a wrong format.
Thanks.
Anyways, I want a function where I can pass in an array of strings (variable
count, variable size), so I defined this:
void Test(LPCTSTR* ppsz, int nCount)
{
for (int nIndex = 0; nIndex < nCount; nIndex++)
TRACE(".%s.\n", ppsz[nIndex]);
}
and call it like:
TCHAR sz[5][32] =
{
"United States",
"Canada",
"Mexico",
"United Kingdom",
"South America"
};
Test((LPCTSTR*)&sz, 5);
The Test function crashes no matter what I do (various indirection styles,
etc) even on nIndex = 0?!?!?!
How can I do this? Would the Test function need to know the 32 to get the
next pointer...
Seems like what I want to do is pass in an array of pointers?
Any simple way to do that similar to the above? without new and delete and
so forth and not using a string list class?
this is for an API that I am writing, so I want minimal dependencies and
minimum chance for a developer to pass me a wrong format.
Thanks.