mmn

closed account (D9hk4iN6)
nbn
Last edited on
1. use [code][/code] tags http://www.cplusplus.com/articles/firedraco1/
2. say what the errors are about http://www.cplusplus.com/articles/how_to_ask/
You have failed to open and read the contents of the filename entered at the command line for starters
It should be along these lines

int main()
{
// Get file name and open file
string fname, junk;
ifstream fin;

cout << "Enter file name: ";
cin >> fname;
fin.open(fname.c_str()); // and open the file for reading
if (fin.fail()){ // we failed to open the file so quit
cerr << "Unable to open file " << fname.c_str() << endl;
exit(1);
}



// Allocate array of students and read data from file
string array_of_students;
while (!fin.eof()){ // while we are not at the end of file
getline(fin,junk); // read one line from the file
array_of_students.append(junk); // create an array of student
array_of_students.append(" "); // place a space between each line of data or "\n a newline
}

fin.close(); // close the file

// here you have a string with the contents of the filename entered.
// do your sorting ect here
cout << array_of_students << "\n";

It would make sense to use the STL library and use vectors or a list. That way you can use the STL to sort unique ect

regards mikeofthenight
Topic archived. No new replies allowed.