>how do make that happen?
The way you want to...you don't. If you really must have something like this then create a wrapper structure or use an STL map. You should prefer the latter, but here is a crufty example of the former:
Code:
#include <iostream>
#include <cstring>
using namespace std;
struct test // structure of the cards
{
char fname[15];
char lname[15];
char age[3];
char tel[13];
char bdate[9];
};
struct wrap
{
char name[20];
test content;
};
char temp[5][15];
void direct(wrap *list, int index)
{
strcpy ( list[index].name, temp[1] );
strcpy ( list[index].content.fname, temp[0] );
strcpy ( list[index].content.lname, temp[1] );
strcpy ( list[index].content.age, temp[2] );
strcpy ( list[index].content.bdate, temp[3] );
strcpy ( list[index].content.tel, temp[4] );
}
void create(wrap *list, int index) // gather info and put them into cards
{
cout <<endl<< "Enter first name :"<<endl;
cin>>temp[0];
cout <<endl<< "Enter last name :"<<endl;
cin>>temp[1];
cout <<endl<< "Enter age :"<<endl;
cin>>temp[2];
cout <<endl<< "Enter birth date (DD/MM/YY) :"<<endl;
cin>>temp[3];
cout <<endl<< "Enter phone number :"<<endl;
cin>>temp[4];
direct(list, index);
cout <<endl<< "card created!" <<endl<< endl;
}
// Test driver
int main()
{
wrap stuff[5];
create(stuff, 0);
create(stuff, 1);
create(stuff, 2);
create(stuff, 3);
create(stuff, 4);
for(int i = 0; i < 5; i++) {
cout<< stuff[i].name << endl << stuff[i].content.lname <<", "<<
stuff[i].content.fname << endl << stuff[i].content.age << endl <<
stuff[i].content.bdate << endl << stuff[i].content.tel << endl <<endl;
}
}
-Prelude