Hi,
I'm trying to revise my "knowledge" in C++ and program probably worked is doing something stupid. Program should read from file First name then last name and finally mark that person got, then move to another person and so on. Next step program asks user to enter his score and compare this score with scores which read from file (Mark < Score) and display and write to file everyone who got higher mark than user.
Instead of that program writes to file details of first person from file either she got higher score than user or not (doesn't follow program condition).
Here is a code:
// lab5_q1.cpp : Defines the entry point for the console application.
// fstream.cpp
//
#include <stdafx.h>
#include <fstream>
#include <iostream>
using namespace std;
void main()
{
ifstream InFile;
ofstream OutFile;
char FirstName[20], LastName[20];
int Score;
int Mark;
cout << "Please enter your mark: ";
cin >> Mark;
InFile.open("Records.txt");
InFile >> FirstName >> LastName >> Score;
OutFile.open("HighScores.txt");
OutFile << FirstName << LastName << Score;
while (!InFile.eof())
{
InFile >> FirstName >> LastName >> Score;
if (Mark < Score)
{
cout << FirstName << " " << LastName << " " << Score << endl;
OutFile << FirstName << " " << LastName << " " << Score << endl;
}
}
InFile.close();
OutFile.close();
system("pause");
}
Note: if you want to test this code just create file records.txt with example names i.e
John Doe 65
Jane Smith 42
Carl Young 59
Sarah Jones 77
Kevin Harris 68
Chris Billington 73
I bet it's simple but i'm groping. :doh:
Thanks

