James_Lochhead
March 30th, 2009, 03:23 PM
Hi everyone,
I have been self-teaching myself a bit of C and have a few questions on the ins and outs of integer types.
1) My book makes no mention of the type "char" being a synonym of either "signed char" or "unsigned char", however there is a reference to "char" in a table of min/max values saying having a look at signed/unsigned char. Can be char be used by itself (while still complying to standards) or is the reference in the table just misleading?
2) In the same min/max value table as question 1 there is a reference to int/unsigned int being two OR four bytes. How does it work? Is it dependant on the compiler or the machine? Is this something I should be wary of when trying to develop cross platform code?
3) In the same table again four byte int and four byte unsigned int are listed as having the same maximum value (2,147,483,647). How can this be? Surely this defeats the point of having an unsigned int.
Please don't pull any blows: I am comfortable with binary numbers and C is not my first programming language.
I have been self-teaching myself a bit of C and have a few questions on the ins and outs of integer types.
1) My book makes no mention of the type "char" being a synonym of either "signed char" or "unsigned char", however there is a reference to "char" in a table of min/max values saying having a look at signed/unsigned char. Can be char be used by itself (while still complying to standards) or is the reference in the table just misleading?
2) In the same min/max value table as question 1 there is a reference to int/unsigned int being two OR four bytes. How does it work? Is it dependant on the compiler or the machine? Is this something I should be wary of when trying to develop cross platform code?
3) In the same table again four byte int and four byte unsigned int are listed as having the same maximum value (2,147,483,647). How can this be? Surely this defeats the point of having an unsigned int.
Please don't pull any blows: I am comfortable with binary numbers and C is not my first programming language.