Modifiers in c

Explanation of modifiers in c programming language by examples and questions

Rules for using modifier in c

Rule 1: We cannot use two modifiers of same groups in any particular data type of c.
For example, following declaration of c are illegal:

short long int i;
static auto char c;
signed unsigned int array[5];
pascal cdecl display();

Following are valid declaration of c:

const volatile float f;
signed static long volatile int i;

Question: Is following declaration is valid in c?

1.   intnear * far * huge *p;
2.  char const * const *c;
3.  short short int i;
4.  const const int i;

Rule 2: We can write modifier either before the data type or after the data type. For example, both of following declaration is correct:

unsigned char c;
char unsigned c;

Rule 3: Order of modifier including data type doesn’t affect the meaning of declaration. For example all of the following have same meaning:

int const short extern i;
int extern const short i;
int short extern const i;
const int short extern i;
extern short const int i;

Rule 4: There is one exception in rule 3. POINTER, FUNCTION and INTERRUPT modifier must be written after the data type. For example, in the following declaration:

unsigned const char far *c;
char unsigned const *c;
char far unsigned const *c;
const char far unsigned *c;
far char const unsigned *c;
const unsigned far char *c;

First four declarations are valid as well as equivalent. But last two declarations are invalid.   
List of data types
Primitive data types in c
Modifiers of data types in c
List of modifiers in c
Default modifiers of data types in c
Default data of modifiers in c
Rules of using modifiers in c
Possibles modifiers of given data types in c
Size modifier in c
Size of data types in c
Sign modifier in c
Range of data types in c
Easy way to remember limit of data types in c
Const modifiers in c
Pointers modifier in c
Function modifier in c
Interrupt modifier in c
Volatile modifier in c
Fundamental data types in c
Memory representation of char in c
Memory representation of signed char in c
Memory representation of int in c
Memory representation of signed int in c
Memory representation of double in c
Post a Comment