Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fast question on sizeof() 1

Status
Not open for further replies.

MinnisotaFreezing

Programmer
Jun 21, 2001
120
KR
I understand how sizeof() can give you the number of elements in an array when they are all the same size, as in

int array[] = { 1, 2, 3, 4, 5 };
size_t sizearr =
sizeof( array ) / sizeof( array[0] );

(Lifted from the MSDN)

But why does it work when the elements are different sizes, like:

sysmetrics[] =
{TEXT("STEVE"), TEXT("JACOBE"), TEXT("CHRISTOPHER"};

size_t sizearr = sizeof(array)/sizeof(array[0]);

where size_t would = 3?

(Lifted from Programming Windows")
 
As I see, the second array, is twodimmensional string, but the first is unidimensional array. John Fill
1c.bmp


ivfmd@mail.md
 
Yea, what you have in the second array is basically

char* sysmetrics[];

or an array of character pointers. Its just gonna count the character pointers for you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top