-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
fidlee wrote:
[snip]
> sorry. my mistake.
> it was actually
> 1)
> char a='i';
You defined [a] as a char
You initialized [a] from a character constant.
This is roughly the same as saying
char a = 43;
in that 43 is an integer, and 'i' is an integer.
But, you can still make the assignment, with a loss of precision.
> printf("%d",sizeof(a));
By definition sizeof(char) is 1
So, sizeof(a) is 1
> 2)
> char a='i';
> printf("%d",sizeof('i'));
Here, you take the sizeof of a character constant.
As I said before, character constants (the things in single quotes) are
/integers/ not characters.
Apparently, on your platform, integers are 2 characters wide, so
sizeof('i')
like
sizeof(292)
will return the size of an integer constant (2).
- --
Lew Pitcher
Master Codewright & JOAT-in-training | GPG public key available on request
Registered Linux User #112576 (
http://counter.li.org/)
Slackware - Because I know what I'm doing.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.7 (GNU/Linux)
iD8DBQFDrNRnagVFX4UWr64RArxwAKCUTHBJf9wM3c9Z2+S73L 7s5fyd0gCgmb92
89A/GHd3MfqY1OkCzxn4hmM=
=nRIN
-----END PGP SIGNATURE-----