Opening 2 separate text files, comparing value in each one and sorting them

Hello,
I have an assignment in which I need to open 2 .txt files, each text file

The first file represents the results of test #1 while the second file represents results of test #2. The task is to join the two files into one resulting file. The resulting file would list each student with two numbers - the results of test #1 and #2. The fields shall be separated by exactly one space. If a student is listed in one file only, we assume the student did not do the other test and such student will be awarded 0 points from the other test. Finally, the resulting file shall be sorted according to student names.


So far I have only managed to open both files and create new Structs (called Personas) for each of the people.

#include <iostream>
#include <cstdlib>
#include <string>
#include <fstream>
#include <sstream>
using namespace std;

struct Persona{
string nombre;
int cal;
int cal2;
Persona* next;
Persona* prev;
};

void readItems() {

ifstream file1, file2;
file1.open("C:\\Users\\MAURICIO GARCIA\\Desktop\\list.txt");
file2.open("C:\\Users\\MAURICIO GARCIA\\Desktop\\lista2.txt");

string line,line2;
istringstream is (line),iss (line2);
string name,name2;
string cal,cal2;


cout << "List 1"<< "\n";
cout<<"\n";
while (getline(file1,line)){
istringstream is (line);
Persona* per=new Persona;
per->cal2=0;
is>>per->nombre>>per->cal;

cout << per->nombre << " " << per->cal <<" "<<per->cal2<< "\n ";



}
cout<<"\n";
cout<<"List 2"<< "\n";
cout<<"\n";
while (getline(file2,line2)){
Persona* per= new Persona;

istringstream iss (line2);
iss>>per->nombre>>per->cal2;

cout << per->nombre << " " << per->cal2 << "\n ";

}
cout<<"\n";


file1.close();
file2.close();
}
int main(int argc, const char * argv[])
{
readItems();




return 0;

}

This is about as far as I´ve gotten (in a working version); if anyone has an idea of how to do or any feedback; this I would really appreciate it.
Seem hard for a begginer :s
Topic archived. No new replies allowed.