S
sshock
Hi all,
I want to read from a file into a vector<unsigned char>. Right now my
code looks like this:
FILE* f = fopen( "datafile", "rb" );
enum { SIZE = 100 };
vector<unsigned char> buf(SIZE);
fread(&buf[0], 1, SIZE, f);
The problem is that the vector's constructor initializes the buffer to
all zeroes. I don't want it to initialize to all zeroes. It is
pointless and a waste of time since I will just be reading in from the
file overtop of it.
So, does anyone know how I could eliminate the initialization of the
vector (without switching to a raw array; I really want a vector here)?
I tried to do some things with reserve(), but they didn't help.
Thanks,
Phillip Hellewell
I want to read from a file into a vector<unsigned char>. Right now my
code looks like this:
FILE* f = fopen( "datafile", "rb" );
enum { SIZE = 100 };
vector<unsigned char> buf(SIZE);
fread(&buf[0], 1, SIZE, f);
The problem is that the vector's constructor initializes the buffer to
all zeroes. I don't want it to initialize to all zeroes. It is
pointless and a waste of time since I will just be reading in from the
file overtop of it.
So, does anyone know how I could eliminate the initialization of the
vector (without switching to a raw array; I really want a vector here)?
I tried to do some things with reserve(), but they didn't help.
Thanks,
Phillip Hellewell