Hi!
I have this simple movie-list that I wont work, I get compile errors on this simple program. Could someone please help me to get this to work, should be very simple for you guys =)
Thanks in advance!
Here's the code:
#include <iostream>
#include <cstdlib>
#include <fstream>
using namespace std;
void sort(char movies[][80])
{
int move, i;
char temp[80];
const int size = 10;
for (move=0; move < size - 1; move++)
{
for (i=0; i<size - 1; i++)
{
if (strcmp(movies[i], movies[i+1]) > 0)
{
strcpy(temp,movies[i])
movies[i] = movies[i+1];
movies[i+1] = temp;
}
}
}
}
//---------------------------------------------------------------------------------------------
int main()
{
int i;
int number;
char list[10][80];
char line[80];
ifstream ifil ("movies.txt");
ifile.getline(line, sizeof(line));
{
strcpy(line,list[number])
number++;
}
while(! ifile.eof())
{
ifile.getline(list[i],80);
i++;
}
cout << "Read " << number << " lines." << endl;
sort(list);
ifil.close();
ofstream ofile;
ofile.open("sorted_movies.txt");
cout<<"Sorted in order \n"<<endl;
ofile<<"Sorted in order\n"<<endl;
for (i = 0; i < sizeof(list)/sizeof(list[0]); i++)
{
cout<<i<<" "<<list[i]<<endl;
ofile<<i<<" "<<list[i]<<endl;
}
ofile.close();
return 0;
}