C
Charlie
My Google Groups search on this one showed the endless debates and I
did my best to look through them to see if my question was answered
and didn't find it. So, here it goes....
From the GG search, I have pretty much gathered and understand why
using sizeof(pointer to char[x]) returns 4 in my program. Is there a
way to get it to return the actual amount of characters?
the basic idea is that I am initializing a char [50] and passing it
into a function that accepts a char*. That function then passes it
into an API as a char* and loads it up with characters. In this case
it is 11 characters long.
As we know.... doing a sizeof() inside of the function that has the
pointer to the original char[50] returns 4. Is there a way to get it
to return the amount of characters (in this case 11)?
Code <clipped>:
//***********
memcpy(inBuffer, _dev.pDeviceType, sizeof(_dev.pDeviceType));
// This returns the first 4 characters out of the 11 total.
// My work around for now....
sprintf(inBuffer, "%s", _dev.pDeviceType);
//***********
did my best to look through them to see if my question was answered
and didn't find it. So, here it goes....
From the GG search, I have pretty much gathered and understand why
using sizeof(pointer to char[x]) returns 4 in my program. Is there a
way to get it to return the actual amount of characters?
the basic idea is that I am initializing a char [50] and passing it
into a function that accepts a char*. That function then passes it
into an API as a char* and loads it up with characters. In this case
it is 11 characters long.
As we know.... doing a sizeof() inside of the function that has the
pointer to the original char[50] returns 4. Is there a way to get it
to return the amount of characters (in this case 11)?
Code <clipped>:
//***********
memcpy(inBuffer, _dev.pDeviceType, sizeof(_dev.pDeviceType));
// This returns the first 4 characters out of the 11 total.
// My work around for now....
sprintf(inBuffer, "%s", _dev.pDeviceType);
//***********