#include <iostream>
#include<string>
#include<vector>
using namespace std;


struct Names
{
    string fname;
    string lname;

void output()

{
    cout<<fname<<" "<<lname;

}

void input()
{
    cin>>fname>>lname;
}


};



struct birth_info
{
    int month;
    int day;
    int year;



    void input()

{
    cin>>month>>day>>year;

}

        void output()

{
    cout<<month<<"/"<<day<<"/"<<year;

}





};





    int main()
    {

        string name[3];
        int i;
        int day[3];
        int month[3];
        int year[3];



        Names names[3];
        birth_info birth[3];
        cout<<"Welcome to The Birthday Program v2"<<endl;


     for (int i=0;i<=2;i++)


     {
         cout<<"Enter First and Last Name"<<endl;
         names[i].input();

         cout<<"The Day"<<endl;
            cin>>day[i];

         cout<<"The Month"<<endl;
            cin>>month[i];

         cout<<"The Year"<<endl;
            cin>>year[i];

     }





           for(i=0;i<3;i++)
        {
                names[i].output();
                cout << ": ";
                birth[i].output();
                cout << endl;
        }


    vector <string> Gifts;

    Gifts.push_back("Guitar");
    Gifts.push_back("Gift Card");
    Gifts.push_back("Moviees");
    Gifts.push_back("books");
    Gifts.push_back("xbox");


int o;
cout <<"Gift Ideas: "<<endl;
for (o=0; o<Gifts.size(); o++)
cout << Gifts[o] << " " <<endl;
cout <<endl;





            return 0;
    }
ok so when i run the program the out put for the last array is supposed to output everyones birth day but it doesn't it outputs the variable addreses or something

any help would be helpfull

thanks#

Recommended Answers

All 3 Replies

Please point out where you're calling birth[i].input().

#include <iostream>
#include<string>
#include<vector>
using namespace std;


struct Names
{
    string fname;
    string lname;

void output()

{
    cout<<fname<<" "<<lname;

}

void input()
{
    cin>>fname>>lname;
}


};



struct birth_info
{
    int month;
    int day;
    int year;



    void input()

{
    cin>>month>>day>>year;

}

        void output()

{
    cout<<month<<"/"<<day<<"/"<<year;

}





};





    int main()
    {

        string name[3];
        int i;
        int day[3];
        int month[3];
        int year[3];



        Names names[3];
        birth_info birth[3];
        cout<<"Welcome to The Birthday Program v2"<<endl;


     for (int i=0;i<3;i++)


     {
         cout<<"Enter First and Last Name"<<endl;
         names[i].input();

         cout<<"Enter The Day, the month and year"<<endl;
         cin>>birth[i].input();


     }





           for(i=0;i<3;i++)
        {
                names[i].output();
                cout << ": ";
                birth[i].output();
                cout << endl;
        }


    vector <string> Gifts;

    Gifts.push_back("Guitar");
    Gifts.push_back("Gift Card");
    Gifts.push_back("Moviees");
    Gifts.push_back("books");
    Gifts.push_back("xbox");


int o;
cout <<"Gift Ideas: "<<endl;
for (o=0; o<Gifts.size(); o++)
cout << Gifts[o] << " " <<endl;
cout <<endl;





            return 0;
    }
OK ichanged the code for the birth info but another error came up on the gift code

but another error came up

If you're going to paste over 100 lines of poorly formatted code with every post then I'll have to ask that you fix the formatting. If you're going to say vague things like "it doesn't work" or "I'm getting an error", I'll direct you here.

kthxbye.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.