I know how to open the file etc, just trying to figure out how to pick up one block from the student file I have attached and read the N only. Here's my code so far, thanks.
//---------------------------------------------------------------------------
#include <vcl.h>
#include <tchar.h>
#include <iostream>
#include <fstream>
#include <conio.h>
using namespace std;
const char STUDENT[] = "C:\\students";
const char COURSES[] = "C:\\courses";
class Student
{
char first_name[ 16 ];
char second_name[ 16 ];
int id_number;
char enrolled;
};
class Course
{
int course_identifier;
char course_name[ 32 ];
int credits;
int id_number;
};
fstream MyFile1( STUDENT , ios :: binary | ios :: in | ios :: out );
fstream MyFile2( COURSES , ios :: binary | ios :: in | ios :: out );
//---------------------------------------------------------------------------
int _tmain(int argc, _TCHAR* argv[])
{
if ( ! MyFile1 )
{
fstream MyFile1( STUDENT , ios :: binary | ios :: out );
}
MyFile1.close();
MyFile1.open( STUDENT , ios :: binary | ios :: in | ios :: out );
if ( ! MyFile1 )
{
cout << "File Error";
getch();
return 1;
}
if ( ! MyFile2 )
{
fstream MyFile2( COURSES , ios :: binary | ios :: out );
}
MyFile2.close();
MyFile2.open( COURSES , ios :: binary | ios :: in | ios :: out );
if ( ! MyFile2 )
{
cout << "File Error";
getch();
return 1;
}
cout << "************************" << endl;
cout << "* 159.234 Assignment 2 *" << endl;
cout << "* 05155932 Syms C. *" << endl;
cout << "* S2 2012 *" << endl;
cout << "************************" << endl << endl;
cout << "Students not enrolled in any paper: " << endl;
getch();
return 0;
}
//---------------------------------------------------------------------------
Output should look something like:
Students not enrolled in any paper:
Blake, James: ID 7177323, paid fees N
Cheers.
Attached File(s)
-
students.txt (128bytes)
Number of downloads: 23
This post has been edited by rdhc1330: 06 August 2012 - 09:21 PM

New Topic/Question
Reply



MultiQuote






|