Re: Using MBCS in a UNICODE defined project
This looks odd:
if( fgets( buffer, sizeof(buffer)/sizeof(buffer[0]), f ) )
Does fgets really count characters the way MSDN says? Or does it use the
word "characters" with the meaning of "bytes", as would happen when copying
and pasting from the C or C++ standard?
MSDN says that Visual Studio 2005 added an optional ccs specification to the
second parameter of _tfopen but you didn't use it. If you did use it, it's
not exactly obvious if there would be some effect on the way fgets and
fgetws and _fgetts count characters.
"Mihai N." <nmihai_year_2000@yahoo.com> wrote in message
news:Xns9930E709A4775MihaiN@207.46.248.16...
Can you give me a code example of this please?
Error checking is minimal and input file name is hard-coded
so that it the code is small and clear.
You can adapt from here.
================================================
#include <stdio.h>
#include <tchar.h>
#include <io.h>
void TestFunction(char * input) {
printf( _T("Received: %s"), input );
}
int _tmain( void ) {
FILE *f = _tfopen( _T("test.txt"), _T("rt") );
if( f ) {
char buffer[1024];
while( !feof( f ) ) {
if( fgets( buffer, sizeof(buffer)/sizeof(buffer[0]), f ) )
TestFunction( buffer );
}
fclose( f );
}
return 0;
}
================================================
--
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email