hi,
i have started learning c for 1 week and i am using VS 2005.
from tutorials i learned that size of char is 1 byte
i am using 32bit system
but i tried this program:
# include<stdio.h>
void main()
{
char a,b;
a=0xfffffffffffffffe; //now a is holding 8bytes thst is sizeof a double datatype
b=0x1;
b=a+0x1;
printf("size of varaible A:%d\n",sizeof(a));
printf(value in a is:%x\n value in b is:%x);
return;
}
output was
size of varaible A:1
value in a is:fffffffe
my question are:
1)when i added one more f in "a" variable a=0xfffffffffffffffef then when i compiled it showed me the error constant too big(bcoz its more than 32 bit) then why it didnot show earlier this erro message when i assigned value(0xfffffffffffffffe) to char a which greater than it can hold ie 0xff(1 byte size maximum valu that char can hold)
2)
even if "A" has holded the whole 8 bytes in it then why did take only last 4 bytes for calculation?
Or VS 2005 itself expands the datasize from char to float or double ?
Please help