A newby question on the sizeof operator
letīs say you got this function:
void DoSomething( char* mystring)
{
........\\;
whatever;
}
and you pass an array to it like this:
char teststring[] = "this is some text";
DoSomething( teststring );
how in GODS NAME! can you get the number of elements of the array INSIDE the function?? (without using strlen() ofcourse, or supose the array is of integers)
iībe tried the usual:
int mylen = sizeof mystring / sizeof mystring[0];
but it wont work, my guess is that im getting the size of THE POINTER to the array NOT the array itself.
i also tried changing the function to take an array NOT a pointer (but of course its the same thing, since only the address of the array gets passed. (right?)
is there a way to solve this? (not including passing the size to the function as an argument of course)
thanks.:confused: