how to do pointer typecast?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • karthik141
    New Member
    • Nov 2011
    • 2

    how to do pointer typecast?

    I am working on console application in visual studio 2008.
    I want to read a value from console window which is of form "T_414_A" which is a macro internal to the code and is defined as some hexadecimal value. how to get that macro value?

    the code which i tried is as follows:
    typedef unsigned long UINT32;
    typedef unsigned char UINT8;
    void * text_data_vp;
    UINT32 * bit_format_ref;
    UINT8 Size;

    printf("Enter the dynamic_data_vp value: ");
    scanf("%d", &text_data_v p);
    bit_format_ref = ((UINT32 *)&text_data_vp );
    Size = HmStrLngTable1[*bit_format_ref];

    from the value i get i need to get some other value from the "HmStrLngTable1 " array?
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    You cannot change or set the value of a macro in runtime, because macro is processed in compile time only

    Comment

    • karthik141
      New Member
      • Nov 2011
      • 2

      #3
      probably i think you didn't understand what i have asked. i am trying to read the name of the macro from compile and and trying to get the value of macro which i have already written in the code.

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        The macro name is not in your compiled code. What is in your compiled code is the value of the macro.

        Remember, a macro is a compile time evaluation. You source code is copied to a new file that contains the original code except the macro name is replaced by the value of the macro. This new temporary file is called a translation unit and it is this file that is compiled.

        Comment

        • johny10151981
          Top Contributor
          • Jan 2010
          • 1059

          #5
          Thanks weaknessforcats for finding the right word

          Comment

          Working...