1234 'x' 9.89 "String"Constants are used to assign a value to a variable. E.G
int i; /* declare a variable called 'i' */ i=1234; /* assign the constant value 1234 to * the variable 'i' */ i++; /* Change the value of the variable. */
1234 (decimal) 0xff (Hexidecimal) 0100 (Octal) '\xf' (Hex character)Examples of their use are:
int i=255; /* i assigned the decimal value of 255 */ i-=0xff /* subtract 255 from i */ i+=010 /* Add Octal 10 (decimal 8) */ /* Print 15 - there are easier ways... */ printf ("%i \n", '\xf');Integer constants are assumed to have a datatype of int, if it will not fit into an 'int' the compiler will assume the constant is a long. You may also force the compiler to use 'long' by putting an 'L' on the end of the integer constant.
1234L /* Long int constant (4 bytes) */The other modifier is 'U' for Unsigned.
1234U /* Unsigned int */and to complete the picture you can specify 'UL'
1234UL /* Unsigned long int */
123.4 1e-2
'x' '\000' '\xhh' escape sequences
An example of a string would be:
char *Str = "String Constant";See the discussion on strings for more information.
Top | Master Index | Keywords | Functions |
author | Tobias Klauser <tklauser@distanz.ch> | 2016-10-20 15:44:19 +0200 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2017-02-15 10:34:18 +0100 |
commit | 5db4992d8f040b8d8db0b86d42806e0c417f7ccf (patch) | |
tree | 5b06e952af482d45f3ade64e77824662e34b7fa2 /arch/powerpc/kvm/book3s_hv_hmi.c | |
parent | 370ebb0ef6255132373ed35d13e7b1d8d2eb7003 (diff) |