|
DavidCrow wrote: What about:
if (&stdout == &stderr)
That won't compile under Visual C++
The standard says that stdout and stderr are macros that evaluate to FILE pointer rvalues. Taking the address them seems suspicious from the outset...
David
---------
Empirical studies indicate that 20% of the people drink 80% of the beer. With C++ developers, the rule is that 80% of the developers understand at most 20% of the language. It is not the same 20% for different people, so don't count on them to understand each other's code.
http://yosefk.com/c++fqa/picture.html#fqa-6.6
---------
|
|
|
|
|
DQNOK wrote: Any ideas?
Does GetStdHandle() help?
Nibu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
Nibu babu thomas wrote: Does GetStdHandle() help?
I'll look into it. Thanks for the idea.
David
|
|
|
|
|
Nibu babu thomas wrote: Does GetStdHandle() help?
From reading the MSDN site, I thought it would; but it doesn't do what I thought.
HANDLE stderrHndl = GetStdHandle(STD_ERROR_HANDLE);
HANDLE stdoutHndl = GetStdHandle(STD_OUTPUT_HANDLE);
...
(very incomplete!)
vfprintf( stderr, msg, args );
if( stderrHndl == stdoutHndl )
goto logprint;
vfprintf( stdout, msg, args );
logprint:
Because the stderrHndl == stdoutHndl is always evaluating to FALSE, I'm still double printing to the console.
David
|
|
|
|
|
If your output is being flooded why dont you just re-direct stderr to a file.
console_app 2> stderr.log
|
|
|
|
|
I like that idea.
But this needs to be general. It's an "alert" library (a very minature logging library) that needs to detect on its own whether stderr has already been redirected.
Key idea: *auto-detect* where stderr is outputting to, and if it's going to stdout, skip over the requirement to write to stderr.
vprintf( alertMsg, msgArgs );
if( stdout != stderr )
vfprintf( stderr, alertMsg, msgArgs );
...
(Note: code is not complete; it needs some complicating va_end and va_starts in there to make it work correctly. Don't use it as a model!)
David
---------
Empirical studies indicate that 20% of the people drink 80% of the beer. With C++ developers, the rule is that 80% of the developers understand at most 20% of the language. It is not the same 20% for different people, so don't count on them to understand each other's code.
http://yosefk.com/c++fqa/picture.html#fqa-6.6
---------
|
|
|
|
|
I have a LONG variable, x, and I need to use the value as an int for my "for" loop.
for (int i; i<x; i++)
How do I typecast a 'LONG' variable to an 'int'?
When I declare "i" as a "LONG" variable as such
for (LONG i; i<x; i++)
I get this error: no conversion from 'LONG' to 'LONG'
What should I do?
Thanks.
modified on Monday, June 2, 2008 8:46 PM
<div class="ForumMod">modified on Monday, June 2, 2008 8:47 PM</div>
|
|
|
|
|
Where's the code?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
oups...forgot to ignore HTML tags
for (int i; i<variable; i++)
and
for (LONG i; i<variable; i++)
|
|
|
|
|
You shouldn't have to do anything special to use the LONG.
There's no requirement to use int in a 'for' statement. You can actually
put any valid code you want to in the three expressions (init/condition/loop).
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
It should work even as a type long (I'm not familiar with type LONG: if it's a composite type, then it won't work).
Any reason you can't just cast it to int at the point you are actually using it within the loop?
This should work (provided x is not a composite type)
for( x = someval; x < someotherval; x++ )
{
...
i = (int)x;
}
David
---------
Empirical studies indicate that 20% of the people drink 80% of the beer. With C++ developers, the rule is that 80% of the developers understand at most 20% of the language. It is not the same 20% for different people, so don't count on them to understand each other's code.
http://yosefk.com/c++fqa/picture.html#fqa-6.6
---------
|
|
|
|
|
When I compile this code, it compiles with no errors (Visual C++ 6.0)
void test(void)
{
LONG x;
x = 800;
for (LONG i=0; i < x; i++)
{
}
}
|
|
|
|
|
The below code will work.
LONG lVal = 100;
int nVal = static_cast<int>( lVal );
akt
|
|
|
|
|
Hello Folks,
I have started working on an Arabic Language Checker. Since I am new to this Unicode stuff therefore its a very basic level question.
The library function accepts Arabic word to be checked for spelling as wstring.
I have assigned char array the hex equivalent of Arabic word. Now the question is how do I convert this char array to wstring/wchar_t array. I googled this conversion but could not find any appropriate solution.
Kindly advice.
Regards,
Jinbaba
|
|
|
|
|
jinbabaj wrote: I have assigned char array...
Since you are dealing with Unicode, why wasn't wchar_t used instead?
Look at MultiByteToWideChar() , or the A2W() macro.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: Since you are dealing with Unicode, why wasn't wchar_t used instead?
Probably it was not Unicode, but a multibyte encoding such as CP 1256. These go to char arrays.
|
|
|
|
|
|
As the subject says,how to get it?
Thank you!~~
|
|
|
|
|
Get the file icon by calling SHGetFileInfo() with uFlags as SHGFI_ICON and you'll get the HICON handle.
Get the ImageList of your list ctrl and add the file icon to it by calling CImageList::Add() , so that you can add that icon to your list ctrl. For adding new item to list ctrl, refer http://www.functionx.com/visualc/controls/listcontrol.htm[^]
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
|
|
|
The Demo is very good
I know how to set the icon now
Thanks a lot!~~~
|
|
|
|
|
Oh thanks for your votes.
|
|
|
|
|