Hi so I have to create a group of postings into a linked list with arrays not strings.I'm just not sure how to go about getting/converting this information into a linked list?
class Posting
{
public:
Posting(); //Constructor
~Posting(); //Destructor
void user_input(char * input,char* &response);
void create_posting();
void display_posting();//displays the post
private:
//variables used to store information about the users posting
char *post_type;
char *info;
char *place;
char *email;
char *compensation;
char *cost;
char *bedrooms;
char *rent;
char *sqfoot;
};
Posting::Posting()//Constructor
{
post_type=NULL;
info=NULL;
place=NULL;
email=NULL;
compensation=NULL;
cost=NULL;
bedrooms=NULL;
rent=NULL;
sqfoot=NULL;
}
Posting::~Posting()
{
delete[] post_type;
delete[] info;
delete[] place;
delete[] email;
delete[] compensation;
delete[] cost;
delete[] bedrooms;
delete[] rent;
delete[] sqfoot;
}
void Posting::user_input(char *input,char* &response)
{
char temp[500];
cout << input;
cin.get(temp,500,'\n');
cin.ignore(100,'\n');
response=new char[strlen(temp)+1];
strcpy(response, temp);
response[0]=toupper(response[0]);
}
void Posting::create_posting()
{
user_input( "What type of posting is this housing,jobs,free stuff or a item for sale? ",post_type );
user_input( "Give a short description of your posting: ",info);
user_input("What is your location? ", place);
user_input("What is your e-mail? ", email);
user_input("If it's a job enter the compensation: ",compensation);
user_input("If your selling a item what is the cost? Make sure to enter a number more then zero or free if it doesn't cost anything",cost);
user_input("What is the rent? ",rent);
user_input("How much is the square footage?",sqfoot);
user_input("How many bedrooms does it have?",bedrooms);
}
void Posting::display_posting()
{
cout << "This is your posting" << endl;
cout << "Your posting can be found in the section:"<< post_type <<'\t'<<"The location is:"<< place << endl;
cout << "Your description of the posting is: "<< info <<'\t'<< "Your e-mail is: "<< email << endl;
cout << "The cost is: " << cost << endl;
cout << "The rent is: "<< rent << endl;
cout << "The square footage is :" << sqfoot << endl;
cout << "The number of bedrooms are:"<< bedrooms << endl;
}