A painting of me


    1 February 2007, early morning

You can use the sizeof operator in C and C++ to find out the size (in bytes) of a type. For example, if we have defined an array char array[10], then sizeof(array) will return the value 10. sizeof looks like a library function, but it isn’t one, it’s part of the definition of the language itself. The call sizeof array also returns 10. In most cases you can use or drop the parentheses around the operand for sizeof. The one exception to this occurs when trying to determine the size of a type. If a type name is to be the operand for sizeof it must be wrapped in parentheses; if you don’t do this, your program won’t compile. I usually drop the parentheses for calls to sizeof so I can tell at a glance if its operand is a type or a particular variable.



Don't be shy, you can comment too!

Some things to keep in mind: You can style comments using Textile. In particular, *text* will get turned into text and _text_ will get turned into text. You can post a link using the command "linktext":link, so something like "google":http://www.google.com will get turned in to google. I may erase off-topic comments, or edit poorly formatted comments; I do this very rarely.