size of operatot c

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rkgowda
    New Member
    • Apr 2007
    • 2

    size of operatot c

    what is size of empty structure,point er,unoin with eg

    reply me as soon as possible

    ravi
  • Ganon11
    Recognized Expert Specialist
    • Oct 2006
    • 3651

    #2
    It would be a simple task to write a test program and find this out...

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      Originally posted by rkgowda
      what is size of empty structure,point er,unoin with eg

      reply me as soon as possible

      ravi
      Can't you try that for yourself? The answer is highly implementation dependent
      anyway so any answer is as good as the other.

      kind regards,

      Jos

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        I sort of thought that in C empty structures/unions where not legal as part of the standard (since they would be fairly useless).

        I thought that it was only in C++ where it was valid to have an empty structure/union/class because they have a use as the base of other structures/unions/classes.

        Comment

        • weaknessforcats
          Recognized Expert Expert
          • Mar 2007
          • 9214

          #5
          If you have this struct:
          Code:
          struct Data
          {
          
          };
          You are allowed to declare a pointer:
          Code:
          Data* var;
          and this requires the compiler to allow you to put an address of a Data variable in the pointer. Ergo: Creation of a Data variable must be allowed.

          This is right there with
          Code:
          char array[] = "Hello";
          char data = 3[array];
          ;

          Comment

          • Banfa
            Recognized Expert Expert
            • Feb 2006
            • 9067

            #6
            Originally posted by weaknessforcats
            If you have this struct:
            Code:
            struct Data
            {
            
            };
            This would be true except that this is not a valid C structure, it is only valid in C++ and the title states this is a C question.

            Comment

            Working...