Hello I have been trying to do a program where the compiler takes from a txt file scores and outputs them in ascending order but it is not working any ideas on what is wrong? And how would I be able to turn this into a array?
Here is my infile.txt that I am working with: 1 John Doe 23567 2 Larry Bird 21889 3 Michael Jordan 21889 4 James Bond 13890 5 Gary Smith 10987 6 GJ 9889 7 Vivien vien 8990 8 Samantha Carl 6778 9 Gary Lewes 5667 10 Sybil Saban 4677
#include <iostream>
#include <fstream>
#include <string>
using std::ifstream;
using namespace std;
int main ()
{
ifstream file_("infile.txt");
int highscore;
std::string name;
int id;
if (file_.is_open())
{
while(file_>>id >> name >> highscore)
{
std::cout<<id << " " <<name << " " <<highscore<<"";
}
file_.close();
}
system ("pause");
return 0;
}
Aucun commentaire:
Enregistrer un commentaire