[OCLUG-devel] sizeof () works differently on char's, int's, etc.
James Colannino
james at colannino.org
Wed Jun 2 21:34:59 PDT 2004
Hey everyone. I used the following to test how the sizeof() function
measures arrays of various variable types:
#include <stdio.h>
char line[10];
int integer[10];
float floaty[10];
int main()
{
printf ("\nCharacter: %d\n", sizeof(line));
printf ("Integer: %d\n", sizeof(integer));
printf ("Floating: %d\n\n", sizeof(floaty));
return 0;
}
My output came out as the following:
Character: 10
Integer: 40
Floating: 40
So my question is this: why does the sizeof() function work with
character arrays but not with numerical ones? Is the sizeof() function
only intended to be used for characters and not for numbers? This has
me very confused.
James
--
My blog: http://www.crazydrclaw.com/
My homepage: http://james.colannino.org/
"There are no uninteresting things; only uninterested people." --G.K.
Chesterton
More information about the OCLUG-devel
mailing list