prob in finding the size of an pointer?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AnagJohari
    New Member
    • May 2010
    • 96

    prob in finding the size of an pointer?

    hello guys
    i write an program
    void main()
    {
    char far *s1,*s2;
    printf("%d%d",s izeof(s1),sizeo f(s2);
    getch();
    }


    i tell u the ans of this that
    42
    i m not able to understand why 42 is the ans plz tell the reason of this.....
  • newb16
    Contributor
    • Jul 2008
    • 687

    #2
    Because it's the Answer to Life, the Universe, and Everything.
    Apparently 'far' modifier is an attribute of '*', so the first pointer is far, and its size is 4, and the second is 'near', with size of 2. Writing the format string as "%d %d" (with space) may help.

    Comment

    • Dheeraj Joshi
      Recognized Expert Top Contributor
      • Jul 2009
      • 1129

      #3
      Yep. It must be 4 2 not 42. use newb16's idea of giving the space between the %d's.

      Regards
      Dheeraj Joshi

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        Looks like you are using something like Windows 3.11

        That is the only platform I know of that had the concept of far pointers. A near pointer (default for char *) was only capable of addressing memory in the programs data sector which was 64k bytes and only required a 16 bit 2 byte pointer. A far pointer was capable of address any address on the computer and so was 32 bit.

        In fact all addresses consisted of a 16 sector and a 16 bit offset in the sector. Sectors could overlap in theory and for the programs own data sector the sector was fixed so it was required to access program memory.

        Comment

        Working...