How to check and comapre content of two structures

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • harisrinu
    New Member
    • Sep 2007
    • 3

    How to check and comapre content of two structures

    How can we check whether the contents of two structure variables are same or not?

    What is the difference between an enumeration and a set of pre-processor # defines?

    What is the maximum combined length of command line arguments including the space between adjacent arguments?
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Originally posted by harisrinu
    How can we check whether the contents of two structure variables are same or not?
    You compare all the members of the structures. If you try to use something like the memcmp function you will run into trouble because the could be padding in the structure and although the members are the same the structure padding could contain different values effects the comparison result.

    If you are using C++ overload operator = for the structure to do a comparison for you allowing you to use == in you code.

    Originally posted by harisrinu
    What is the difference between an enumeration and a set of pre-processor # defines?
    What do you think the differences are?

    Originally posted by harisrinu
    What is the maximum combined length of command line arguments including the space between adjacent arguments?
    It is platform dependent.

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      Originally posted by JosAH
      If you are using C++ overload operator = for the structure to do a comparison
      Typo. He means you should overload operator==.

      Comment

      • kreagan
        New Member
        • Aug 2007
        • 153

        #4
        Originally posted by harisrinu
        What is the difference between an enumeration and a set of pre-processor # defines?
        pre-processor = string substitution during compile time.
        enumeration = counting. (I would suggest reading more about enumeration).

        Comment

        • weaknessforcats
          Recognized Expert Expert
          • Mar 2007
          • 9214

          #5
          Originally posted by kregan
          pre-processor = string substitution during compile time.
          enumeration = counting. (I would suggest reading more about enumeration).
          Close.

          preprocessor -> substitution before the compile starts. Compiler cannot check validity of the expansion.

          enumeration -> named integer values. It's a bigger area then just counting. enums are part of C/C++ and the compiler can check for correct usage and value.

          Comment

          Working...