ok i want to read a file into a buffer a line at a time, but atm the moment it reads the whole file and i am not sure how to sort this out
Code:
// Cfunctions.cpp: implementation of the functions class.
//
//////////////////////////////////////////////////////////////////////
#include "functions.h"
#include <iostream>
#include <windows.h>
#include <fstream.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Cfunctions::Cfunctions()
{
}
Cfunctions::~Cfunctions()
{
}
Cfunctions::Printall()
{
system("cls");
ifstream file;
file.open("flight.txt",ios::nocreate);
if(!file)
{
cout<<"UNABLE TO OPEN FILE!!";
goto end;
}
while(file)
{
file.get(ch);
if (ch=='~')
{
ch=NULL;
}
if (ch=='%')
{
ch=NULL;
}
if (ch=='#')
{
ch=NULL;
}
cout << ch << flush;
}
getch();
end:
file.close();
return 0;
}
int Cfunctions::Flightdetails()
{
int length1;
char * buffer;
cout << "Please enter flight number" << endl;
cin >> flightno;
system("cls");
ifstream is;
is.open("flight.txt",ios::nocreate);
is.seekg (0, ios::end);
length1 = is.tellg();
is.seekg (0, ios::beg);
buffer = new char [length1];
is.read (buffer,length1);
is.close();
cout.write (buffer,length1);
return 0;
}
can anyone help?