Re: How to read Unicode(Big-Endian) text file(s) in Non-MFC
meme wrote:
"Ben Voigt [C++ MVP]" <rbv@nospam.nospam> wrote in message
news:uJVWa09cIHA.4844@TK2MSFTNGP04.phx.gbl...
Let's make a simple change. Test the result of fread and return a
boolean indicating whether the read was successful. With #2, you
just do: if (fread(&data[0], sizeof(char), flen-3, file) < flen - 3)
return
false; ...
return true;
With #1, you've got to duplicate all the cleanup logic at every exit
point.
Ah! hmmm! so you are saying I don't have to care for the clean-up code
anymore if I use vector....in fact there is no code for clen-up....
Not exactly. The cleanup code is specially designated by being in a
"destructor", and you can trust the compiler to run it no matter how you
leave the function (reach end, return statement, exception, etc.)
just allocate and forget.... like in other languages .... ohho...
that's a pretty good news....
When you start writing your own destructors you will have to remember it,
but not for just using the library objects.
well then next question is is there any good online resources for STL
? besides MSDN...
Google "std::vector".
Here's one of the hits: http://www.cppreference.com/cppvector/index.html
If you know any... please let me know....
Thank you very much :-D
PS: BTW Is this MS specific... can I use it on other compilers like
borland...
std::vector is part of the C++ Standard Library, which should be supported
by any C++ compiler (at least in theory... any compiler that doesn't support
it is not really C++, but then there'd be NO C++ compilers at all because
none of them follow the standard perfectly, the closest one is from Comeau
Computing)