J
justin_davies_2002
i need to read a text file into a character array, so i used an example
fom taken from a cplusplus.com tutorial " Input/ output with files"
(seebelow). The Problem i get is, it only makes a buffer array which
can hold 4 characters when the example text file i created is 30
characters long.
Any Help would be great!!
// reading binary file
#include <iostream.h>
#include <fstream.h>
const char * filename = "example.txt";
int main () {
char * buffer;
long size;
ifstream file (filename, ios::in|ios::binary|ios::ate);
size = file.tellg();
file.seekg (0, ios::beg);
buffer = new char [size];
file.read (buffer, size);
file.close();
cout << "the complete file is in a buffer";
delete[] buffer;
return 0;
}
fom taken from a cplusplus.com tutorial " Input/ output with files"
(seebelow). The Problem i get is, it only makes a buffer array which
can hold 4 characters when the example text file i created is 30
characters long.
Any Help would be great!!
// reading binary file
#include <iostream.h>
#include <fstream.h>
const char * filename = "example.txt";
int main () {
char * buffer;
long size;
ifstream file (filename, ios::in|ios::binary|ios::ate);
size = file.tellg();
file.seekg (0, ios::beg);
buffer = new char [size];
file.read (buffer, size);
file.close();
cout << "the complete file is in a buffer";
delete[] buffer;
return 0;
}