i want help in visual c++ code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • humsafar
    New Member
    • Nov 2008
    • 5

    #1

    i want help in visual c++ code

    Consider the following code:
    struct MyStructure
    {
    char MyString[40];
    int MyInteger;
    };

    MyStructure StructVariable[20];
    MyStructure *StructPointer;

    StructPointer = StructVariable;

    i. Does this code have any error(s)? If there correct it.
    ii. Store some values (in member variables MyString and MyInteger) in 15th element of the array StructVariable using StructPointer.
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    i. What apart from the obvious that you have not put in a main function? The answer rather depends on whether you think you are writing C or C++ code. Have you tried to compile it? What did the compiler say?

    ii. Thank you but with 20 years of programming experience I have no need to attempt such a simple exercise! I suggest you attempt the problem that way you may learn something, there is a fine article on arrays here.

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      Originally posted by humsafar
      If there correct it.
      You forgot to say the magic word; do it yourself it is your homework exercise
      after all.

      kind regards,

      Jos

      Comment

      • humsafar
        New Member
        • Nov 2008
        • 5

        #4
        Originally posted by Banfa
        i. What apart from the obvious that you have not put in a main function? The answer rather depends on whether you think you are writing C or C++ code. Have you tried to compile it? What did the compiler say?

        ii. Thank you but with 20 years of programming experience I have no need to attempt such a simple exercise! I suggest you attempt the problem that way you may learn something, there is a fine article on arrays here.
        thanks but i am not going to compile it i tried and get this solution please tel me is it correct or not
        struct MyStructure
        {
        char MyString[40];
        int MyInteger;
        };

        MyStructure Variable[14];
        MyStructure * Variable Ptr;
        MyStructure Variable = {"hello sir",50};

        Comment

        • JosAH
          Recognized Expert MVP
          • Mar 2007
          • 11453

          #5
          We are not going to compile it for you either; did you try to compile it? What did
          your compiler say about it? We are not a free compiling service nor are we a free
          do-your-homework service.

          kind regards,

          Jos (moderator)

          Comment

          Working...