Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > sizeof in old C...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 7 Topic 25701 of 27343
Post > Topic >>

sizeof in old C compilers

by WDS <Bill@[EMAIL PROTECTED] > Apr 18, 2008 at 10:14 AM

I ran across some old C code that was written something like this:

int array[NUM_ELEMENTS];
.. . .
memset(array, -1, sizeof(int)*NUM_ELEMENTS);

The code is filled with this idiom on memsets (and memcpys and ...).
I am trying to figure out why they just didn't code it this way:

memset(array, -1, sizeof(array));

The only thing I could think of is there was a time when
sizeof(somearray) didn't return the whole array's size.  Anyone
remember anything like that from old, old C compilers?  The oldest
reference I can find is from a 1988 printing of The C Programming
Language and even there sizeof works as today.

Of course the original authors may not have understood sizeof, too, I
suppose.
 




 7 Posts in Topic:
sizeof in old C compilers
WDS <Bill@[EMAIL PROTE  2008-04-18 10:14:36 
Re: sizeof in old C compilers
Ben Bacarisse <ben.use  2008-04-18 18:32:45 
Re: sizeof in old C compilers
"Serve L" <n  2008-04-19 10:09:14 
Re: sizeof in old C compilers
"Default User"   2008-04-19 17:45:24 
Re: sizeof in old C compilers
Eric Sosman <Eric.Sosm  2008-04-18 13:48:37 
Re: sizeof in old C compilers
Andrey Tarasevich <and  2008-04-18 10:59:08 
Re: sizeof in old C compilers
Ben Bacarisse <ben.use  2008-04-19 10:21:29 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Sep 6 21:22:23 CDT 2008.