Is the following code OK?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • vb@gmail.com

    #1

    Is the following code OK?

    hi all,
    I have to compare an address of structure with an absolute address(this
    address signifies the start of a memory component).
    Now my question is the follwong code leagal:-

    #include <stdio.h>

    int main()
    {
    struct t{
    int a;
    int b;
    }temp;

    struct t* ptr=&temp;

    if(ptr<0x120000 )
    printf("What\n" );
    else
    printf("The hell\n");
    return 0;
    }

    My concern is the comparision in the if statement because a structure
    pointer and an unsigned int are being compared. Can there be an
    undefined behaviour in any cases ?

Working...