#include <iostream>
usingnamespace std;
struct database {
int age;
int salary;
string name[100];
string hob[1024];
};
int main()
{
database per;
string *p;
string *h;
p = &per.name[100];
h = &per.hob[1024];
int x;
do{
cout<<"Hello and welcome to this small little program that I put together. First off please enter your name:";
cin>>per.name[100];
cout<<"So "<<*p<<" would you like to tell me a little bit more about yourself? \n";
cout<<"1.Yes \n2.No \n Please enter your selection: ";
cin>>x;
cout<<"Good to hear I like learning about new people\n";
do{
cout<<"So "<<*p<<" what is your age?";
cin>>per.age;
if(per.age > 106){
cout<<" WOW! That's super crazy that you're "<<per.age<<" I'm surpirised you know how to work a computer!\n";
cout<<"Why don't you enter your reall age and we can get on with this.\n";
}
elseif(per.age < 5){
cout<<"It is very sceptical to me that you are "<<per.age<<".";
cout<<"Why don't you enter your reall age and we can get on with this.\n";
}
}while(per.age < 5 , per.age > 106);
cout<<"How about your anual salary: ";
cin>>per.salary;
cout<<"\nAlso "<<*p<<" What are some of your hobbies?\n";
cin>>per.hob[1024];
cout<<"Well today so far I have learned.\n";
cout<<"Your name: "<<*p<<endl;
cout<<"Your age: "<<per.age<<endl;
cout<<"Your anual salary: "<<per.salary<<endl;
cout<<"And lastly what you like to do, which is: "<<*h<<endl;
cout<<"Well it's been awesome getting to know you "<<*p<<" 8) Would you like to tell me everything again?!\n";
cout<<"1.Yes! 2.No. :";
cin>>x;
}while(x != 2);
}
string hob[1024] allocates space for 1024 strings in the array hob. Valid indices for hob are 0-1023. Thus, in cin>>per.hob[1024]; the index used is out of range.
Hey thanks again for your help 8) I ended up ditching the strings all together and using arrays instead. Which would have been a better idea to start off with I guess hehe.