Hard Problem :(

This is a discussion on Hard Problem :( within the C++ Programming forums, part of the General Programming Boards category; Code: #include <iostream.h> #include <stdlib.h> //A structure inside another structure struct strEntry { char *first_name; char *last_name; struct strMarriage { ...

  1. #1
    Unregistered
    Guest

    Angry Hard Problem :(

    Code:
    #include <iostream.h>
    #include <stdlib.h>
    
    //A structure inside another structure
    struct strEntry
    {
    char  *first_name;
    char  *last_name;
    
    struct strMarriage
    {
      char *marriage_date;
      char *marriage_city;
    };
    
    };
    
    void  enter_entry (strEntry& person);   //function prototype
    
    ////////////////////////////////////////////////////////////////////////
    
    void main()
    {
    strEntry name;
    enter_entry(name);
    }
    
    ////////////////////////////////////////////////////////////////////////
    
    void enter_entry (strEntry& person)
    {
    int num_marr;
    char space[100];
    
    cout << "First Name: ";
    cin.get (space,99,'\n');
    cin.get ();
    strcpy((person.first_name = new char[strlen(space)+1]), space);
    
    cout << "Last Name: ";
    cin.get (space,99,'\n');
    cin.get ();
    strcpy((person.last_name = new char[strlen(space)+1]), space);
    
    cout << "How many times have you been married? ";
    cin >> num_marr;
    
    new strEntry.strMarriage[num_marr];  //THIS IS WRONG. WHAT SHOULD IT BE?
    
    for (int count=1; count <= num_marr; ++count)
    {
    cout << "Marriage Date " << count << ": ";
    cin.get (space,99,'\n');
    cin.get ();
    //what should be entered here???????
    
    cout << "Marriage City " << count << ": ";
    cin.get (space,99,'\n');
    cin.get ();
    //what should be entered here???????
    }
    
    }
    I am not allowed to use global member names

    The whole point of a structure inside another structure is this:
    There will be several other members such as children,
    so I will also need to ask how many children do they have.
    If I create several structures then I will have to pass several member names, and I don't want to do that. I only want to pass one.

    I can not figure this out

  2. #2
    x4000 Ruski's Avatar
    Join Date
    Jun 2002
    Location
    Outer Space!
    Posts
    542
    Sorry... im not used to pointers
    what does signature stand for?

  3. #3
    Unregistered
    Guest
    never mind i figured it out

  4. #4
    x4000 Ruski's Avatar
    Join Date
    Jun 2002
    Location
    Outer Space!
    Posts
    542
    k, Good Luck
    what does signature stand for?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  2. small reference problem
    By DavidP in forum C++ Programming
    Replies: 6
    Last Post: 06-21-2004, 08:29 PM
  3. Problem with destructors.
    By Hulag in forum C++ Programming
    Replies: 7
    Last Post: 06-11-2004, 01:30 PM
  4. beginner problem
    By The_Nymph in forum C Programming
    Replies: 4
    Last Post: 03-05-2002, 05:46 PM
  5. problem with output
    By Garfield in forum C Programming
    Replies: 2
    Last Post: 11-18-2001, 08:34 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21