Thread: C Struc

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0

    C Struc


    hello
    im soft engineering student and i need some help, i need to do the following:


    1. The program should define and use at least 3 structures A,B and C that have a containment relationship.
    Here are some examples for the relationship between the structures:

    a. A contains B contains C.
    b. A contains B contains a pointer to C.
    c. A contains an array of Bs that contains C.
    d. A contains B that contains a pointer to C.
    e. A contain B that contain an array of C.
    f. A contains an array of Bs that contains a pointer to C.

    Etc….

    I cant find any idea what can contain what..

    thanks.
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,837
    Rep Power
    480
    For this
    a. A contains B contains C.

    I'd declare a struct C,
    then a struct B,
    finally a struct A.

    Reverse order, you see.

    You know how to use typedef or #define ?
    (please show example of your work, not merely "yes".)

    I'd also have my compiler verify what I write with all warnings turned on.

    Don't work "blind". Your compiler is a valuable tool for this project.
    Last edited by b49P23TIvg; December 28th, 2012 at 09:33 AM.
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0
    Originally Posted by b49P23TIvg
    For this
    a. A contains B contains C.

    I'd declare a struct C,
    then a struct B,
    finally a struct A.

    Reverse order, you see.

    You know how to use typedef or #define ?
    (please show example of your work, not merely "yes".)

    I'd also have my compiler verify what I write with all warnings turned on.

    Don't work "blind". Your compiler is a valuable tool for this project.

    in matter of fact i didnot started the assigment yet, its just a shot task from the whole picture:

    2. The program should define and use at least 3 structures A,B and C that have a containment relationship. Here are some examples for the relationship between the structures:
    a. A contains B contains C.
    b. A contains B contains a pointer to C.
    c. A contains an array of Bs that contains C.
    d. A contains B that contains a pointer to C.
    e. A contain B that contain an array of C.
    f. A contains an array of Bs that contains a pointer to C.
    Etc….
    3. At least one of the fields in one of the structures should be a static string (with a predefined size).
    4. At least one of the fields in one of the structures should be a dynamic string (a pointer to char).
    5. There should be a field in one of the structures that is a pointer to another structure. Thus, the contained structure should be allocated dynamically (Think of a situation where the existence of the structure is optional).
    6. The program should use all 3 arrays:
    a. an array of structures (of any type that you declare)
    b. an array of pointers to structures
    c. a matrix of structures.
    7. There should be at least one recursive function.
    8. The program should use at least 3 of the string.h functions.
    9. The project should contain at least 20 functions.
    10. The IO functions should be in a separate module\s.
    11. A user friendly main function should execute all the functions and demonstrate the use of all the functions.
  6. #4
  7. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,837
    Rep Power
    480
    encrypted, 2001 A Space Odyssey:
    Zpv xpvme tvsqsjtf zpvs jotusvdups jg zpv efnpotusbufe uif bcjmjuz up efdmbsf bo bssbz pg joufhfst.

    Hey! Certainly you can knock off some of these challenges.

    Declare a static string with predefined size.
    3. At least one of the fields in one of the structures should be a static string (with a predefined size).

    Show how do declare a pointer to char.
    4. At least one of the fields in one of the structures should be a dynamic string (a pointer to char).


    And be so thankful that you didn't need to declare an array of pointers to functions that take floats as arguments and return pointers to functions that take integer arguments.
    Last edited by b49P23TIvg; December 28th, 2012 at 10:21 AM.
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo