Thread: I hate "C"
View Single Post
  #9   Spotlight this post!  
Unread 20-01-2007, 00:54
dcbrown dcbrown is offline
Registered User
AKA: Bud
no team
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Hollis,NH
Posts: 236
dcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud of
Re: I hate "C"

printf can be passed a variable number of arguments. The passed arguments are saved onto the stack and end up just a long list of bytes - no delimiters. The format statement is parsed to determine the number and size of the passed arguments. So, if measurement is a long - 4 bytes are passed because the caller knows its data type. But if the format statement says %d - print out an int - then the only the first two bytes are pulled from the list of argument bytes. The next %d will then print out the last two bytes of measurement, etc. In C, this is a varargs routine.

Last edited by dcbrown : 20-01-2007 at 01:01.