Regarding Type Checking in C

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pradeepp
    New Member
    • Jul 2007
    • 3

    Regarding Type Checking in C

    Hi All,
    I have one small doubt in C
    I have written a below program

    int main()
    {
    float a;
    int b;
    long c

    c =a + b;
    }

    my question is when the type cheking will happen.
    How should compiler will know a flaot, b int and c is long during execution.
    Where these are stored... in map file?

    Can any one explain me on this.

    Thanks
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    The compiler is not there during execution so it doesn't know anything.

    When you compiled your code, though, the compiler knew what the types of your variables were. Then when the calculation was compiled, it used that information convert your types to a type to be used for the calculation using a process call Arithmetic Conversions, which is part of the ANSI standard.

    Everything you wrote in your code was converted to machine instructions.

    It is those instructions that are being executed.

    Comment

    Working...