file length...
From: Steve (steve_at_nospamplease.com)
Date: 01/31/05
- Next message: Gianni Mariani: "Re: file length..."
- Previous message: Torsten Mueller: "HPUX, shared library and static member variables"
- Next in thread: Gianni Mariani: "Re: file length..."
- Reply: Gianni Mariani: "Re: file length..."
- Reply: Rolf Magnus: "Re: file length..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 31 Jan 2005 09:24:59 +0100
Hi,
I'm trying to read a binary file into a buffer:
std::ifstream ifs(fileName,
std::ios::in|std::ios::binary);
if (!ifs)
return;
ifs.seekg(0,std::ios::end);
int len = ifs.tellg();
ifs.seekg(0,std::ios::beg);
char* buf = new char[len];
memcpy(buf,ifs.rdbuf(),len);
However, this is not working as expected since
buf contains not what the original file contains...
I do not want to read character-by-character from
file and the above does not work. So what is the
correct way of doing this "simple" stuff?
Thanks,
Steve
- Next message: Gianni Mariani: "Re: file length..."
- Previous message: Torsten Mueller: "HPUX, shared library and static member variables"
- Next in thread: Gianni Mariani: "Re: file length..."
- Reply: Gianni Mariani: "Re: file length..."
- Reply: Rolf Magnus: "Re: file length..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|