Hi I am a learning programmer and I am always looking for help along the way. Right now I am struggling with merging two lists into a third list. Here is what I have so far as you can see is three lists I need help with the merge method - any thoughts?

//STLList - use the list container of std library
#include <list>
#include <string>
#include <cstdio>
#include <iostream>
//declare three list of objects
using namespace std;
list <string> Anames;
list <string> BastroSigns;
list <string> MergedNamesSigns;
int main()
{
// input string
cout << "input data - name - input 0 to end" << endl;
while (true)
{
string name;
cin >> name;
if (( name.compare("x") == 0) || (name.compare ("x") == 0))
{
break;
}
Anames.push_back (name);
}
// sort list
Anames.sortedInsert ();
//display list A
cout << "output is: " << endl;

while (!Anames.empty())
{
// get first on list
string name = Anames.front();
cout << name<< endl;
// remove displayed name from list
Anames.pop_front();
}
cout << "output is: " << endl;

while (!Anames.empty())
{
// get first on list
string name = Anames.front();
cout << name<< endl;
// remove displayed name from list
Anames.pop_front();
}
// input string
cout << "input data - astrological sign - input 0 to end" << endl;
while (true)
{
string sign;
cin >> sign;
if (( sign.compare("x") == 0) || (sign.compare ("x") == 0))
{
break;
}
sign.push_back (sign);
}
// sort list
BastroSigns.sortedInsert ();
//display list B
cout << "output is: " << endl;

while (!BastroSigns.empty())
{

Recommended Answers

All 2 Replies

sorry - i was excited to join and in my exhuberance went right into discussing c++.

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.