On Nov 5, 7:51 am, Matrixinline <anup.kata...@g mail.comwrote:
Here is my problem I am using a Unicode project
and I tried to read the File like
sPath = LPCTSTR;
FILE* oFp = _tfopen(sPath,L "r");
while(!feof(oFp ))
{
if (fgets(sReadDat a, 3072, oFp) != NULL)
{
sStringBuffer +=sReadData;
}
}
fclose(oFp);
This doesn't look like C++ to me, although there are some legacy
C++ functions involved. Still, if _tfopen returns a C
compatible FILE* (which would seem to be the case if you use
feof, fgets and fclose on it), then I can see some real
problems: I'm not familiar with the .BMP format, but if it's
binary (or really any exterally defined format), you should open
in binary mode. And fgets (the C equivalent of getline) reads
lines of text, not binary data.
But when I tried to Read a *.BMP file I get BM6 in the
Buffer sStringBuffer. after that It encounters end of file and
closes down.
Just a guess, but if you're under Windows, reading a file in
text mode, you'll see an EOF the first time you encounter a byte
with 0x1A.
Can you please let me know where I am making a mistake to read
files.
Without knowing really what kind of data you are trying to read,
it's difficult to say. If it's text data, try forgoing the
non-standard stuff, and just use std::istream. If it's binary,
the question is a bit more complex; depending on the
application, std::istream or std::streambuf might be the
solution, or it might be preferable to go directly to the system
level.
--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34