Type specifiers and type qualifiers in C .

Home Forums C-programming.. Type specifiers and type qualifiers in C .

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #2305 Reply
    Humble
    Keymaster

    There are type specifiers and type qualifiers in C .. “enum” , “void”..etc are examples of type specifiers and “volatile”, “const” etc are examples for type qualifiers..

    enum:

    Enumarated data or enum is one type specifier which allows you to define a fixed set of words that a variable of type enum can take as its value. The words are assigned integer values by the compiler so that code can compare enum variables.

    void :

    “void” bascially represent an empty area, but please note that its not invalid. void can be used when you prototype a function which returns nothing , when declaring a pointer or when declaring a variable ( void variables cannot be used in any way, so does not make sense ).

    Regarding void pointers refer # https://humblec.com/forums/topic/void-pointer-in-c/

    volatile:

    The volatile keyword ensures that the variable is fetched from memory on every access. Really useful in case of memory-mapped variables.

    *) Compiler will not optimize those variables
    *) Always latest copy is read
    *) Different programs or executions can access this shared variable without any issue.
    *) In other way it convey that , this is getting changed autonomously.
    *) Volatile variables are also flagged by the compiler as not to be stored in read-only memory.


    const:

    ‘const’ type qualifier stands for “constant objects”. This type of variable must be assigned a value once and once only. More or less think that it might be in read-only memory. The reserved word const is, like static and volatile, a data type qualifier that can be applied to many different data types. It declares a variable to be a constant, whose value cannot be reassigned. A const must be assigned a value when it is declared.

    Any attempt to assign a new value to a const variable will result in a compile-time error.

Viewing 1 post (of 1 total)
Reply To: Type specifiers and type qualifiers in C .
Your information: