how to search my text file

Hey guys. I'm relatively new to programming in c++, could someone take a look at my source code, and steer me in the right direction here please.

This is what i'm trying to do.
1[s]). The program should to be able to read a text file with the records in it.(DID THAT[/s])
2). I want to search the records using strings in the text file (Haven't done this)
3) Also, to sort the records from highest to loweest using the decimal numbers or double in text file



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//Here is the code
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

//double hu;
//string

int main () 
 {
  string line;
  ifstream myfile ("testfile.txt");
  if (myfile.is_open())
 {
    while ( myfile.good() )
 {
      getline (myfile,line);
      cout << line << endl;
 
 }
    myfile.close();
 }

else cout << "Unable to open file"; 

char c;
cout<<"\n enter a character and enter to exit: ";
cin>>c;
return 0;
}


These are the records in text file


aRecord 90 90 90 90 22.5
bRecord 96 90 90 90 23.9
cRecord 87 90 100 100 19.9
dRecord 100 100 100 100 25.5
eRecord 67 34 78 32 45 13.5
fRecord 54 45 65 75 34 9.84
gRecord 110 75 43 65 18.56


Reguards
Last edited on
Topic archived. No new replies allowed.