#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
int main()
{
const int SIZE=81;
char input[SIZE];
fstream nameFile;
nameFile.open("Bands.txt", ios::in);
if (!nameFile)
{
cout << "Error: Cannot open file." << endl;
return 0;
}
nameFile.getline(input, SIZE);
while (!nameFile.eof())
{
cout << input << endl;
nameFile.getline(input, SIZE);
}
nameFile.close();
system("PAUSE");
return EXIT_SUCCESS;
}
Bands.txt :
1 10 Led Zeppelin
3 9 Guns 'n Roses
10 1 Mariah Carey
5 6 Pink Floyd
6 5 Pearl Jam
4 8 Boston
7 3 Bon Jovi
8 3 TLC
9 2 MC Hammer
2 9 AC/DC
I'm new at Programming and am entirely unsure of what to do. All I managed to do was print exactly what is in the txt file, but I have no idea how to loop to make them in order or change the sales to *'s.
The Question:
Read the file (there is an unknown number of bands) from Bands.txt
The number of sales is from 0 to 10
The band name is any number of strings long
Output the band information in a graphic to both the screen and a file called "results.txt" as so
1 ********** Led Zeppelin
and they are placed by rank 1-10
The file is in no particular order - at the end of the file print out total sales and the number one band based on rank.