Basic Types

Generally, use int for integer values and double for floating point. The char type is one byte long for holding characters, but it is really just a small integer, holding an ASCII value. Note that characters in Java are Unicode, but C is an older language, where the char type is limited to 256 values.

C has several more basic types than Java does, in various sizes:

Integer Types: charshort intintlong intlong long int
Floating Types: floatdoublelong double

Unlike Java, sizes are not dictated by the standard, but by the compiler writer. The only restrictions are that char should be one byte, and, reading left to right, the sizes should never get smaller. They may be the same, though.

Pretty reliably, int and float will be four bytes, short int two and double eight. The long double type may be 12 or 16. For a long time, long int was also four bytes, but now eight is usual. The long long type is usually eight.

The basic types support the basic operations familiar from Java: +-*/%, and the shortcut versions like += and ++.