hello all ,
im trying to read a text file and display its contents. While i got the code running and the output was displayed perfectly for sometime , i started getting Abort(core dump) error . Am i missing something here ? im using HP-UX.
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
#include <string.h>
int main () {
int length;
char* buff=NULL;
ifstream is;
is.open ("vishy.txt", ios::in );
// get length of file:
is.seekg (0, ios::end);
length = is.tellg();
is.seekg (0, ios::beg);
// allocate memory:
buff = new char [length];
// read data as a block:
is.read (buff,length);
is.close();
cout.write (buff,length);
delete[] buff;
buff = NULL;
}
thanks
vishy