|
kakan wrote: What's wrong with just putting the cursor on functionOne while debugging?
There's nothing wrong, of course.
However maybe handy (handy, I repeat), if putting the cursor on functionOne is not that easy (suppose the function is inside a DLL...).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
True. I missed that functionOne is a function, and not a variable.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Thank you for clearing that one up ... So if I understand correctly:
bool a = false;
if (!a)
int b = -2;
if (!b)
CPallini wrote: Hope that helps.
Yes it did, thanks again.
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
Well...
When it comes to bool values, they are defined as this (if I remember it correctly):
false is always 0, zero.
true is any other value, can be -1 (VARIANT_BOOL) or 1 (true, TRUE).
But stricly, if it has got any other value than 0, it's true.
So if you want to follow the rules, while working with bool variables, always test for zero or not zero.
Test for zero/false:
if (!a), or if(0 == a), or if(a == 0)
Test for true:
if (a), or if(0 != a), or if(a != 0)
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
You're a bit confused, anymore.
if b is declared as an int , then
if ( ! b )
{
}
executes the code inside the block if and only if b==0 , because C/C++ consider a non-zero valued int as true (a zero valued int as false ) and ! is the logical negation operator.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Another trap I have seen beginners make is
int b;
if (b == TRUE)
{
}
is different to
if (b)
{
}
.
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
Actually, both previous answers are wrong: you don't evaluate the result of the function but the address of the function itself.
Oops, you probably wanted to write:
if (!functionOne())
Sorry, I'm tired, stupid joke
|
|
|
|
|
Good point!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Cedric Moonen wrote: // FIRST if (!functionOne())
Sorry ... my bad, forgot to put the "()" in.
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
HI,
How can i get IP adress of my system thru a VC++ application,
thanx in advance..
birajendu
CyberG India
Delhi
India
|
|
|
|
|
you can use GetAdaptersInfo function
|
|
|
|
|
birajendu wrote: How can i get IP adress of my system thru a VC++ application,
Use gethostbyname or getaddrinfo .
|
|
|
|
|
use IPM_GETADDRESS Message
Retrieves the address values for all four fields in the IP address control.
Syntax
To send this message, call the SendMessage function as follows.
lResult = SendMessage( // returns LRESULT in lResult
(HWND) hWndControl, // handle to destination control
(UINT) IPM_GETADDRESS, // message ID
(WPARAM) wParam, // = 0; not used, must be zero
(LPARAM) lParam // = (LPARAM) (LPDWORD) pdwAddr;
);
|
|
|
|
|
How do I enable out-of-bounds memory checking for dynamically allocated memory (new/delete) in VC++ 2003? /RTC options enable stack-based checks, which I've got turned on, but that doesn't cover heap-based allocations.
|
|
|
|
|
Simply you cannot (AFAIK).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Well, I was hoping for a configurable option. Overloading operator new and delete is my backup plan, which will work because I only use new/delete.
|
|
|
|
|
Can you do that?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Of course. Overloading new/delete is part of the C++ Standard. Just tack on some extra bytes (on either side) during allocation and check those bytes before deleting the memory. If a match fails, then something overwrote the memory. Poor-man's solution is to use TRACE() at that point. A stack dump would be nicer. Even better would be the compiler offering the option at compile-time to do all of that without writing any code.
|
|
|
|
|
I didn't know that. thank you.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
The debug CRT does it for you (using sentry bytes I believe).
Try this in a debug build:
BYTE *pBytes = new BYTE[10];
pBytes[10] = 255;
delete[] pBytes;
"If you can dodge a wrench, you can dodge a ball."
|
|
|
|
|
hi i have to display files from a specified drive to a list view control. how to display this with the folder icons.
|
|
|
|
|
Use WIN32_FIND_DATA , FindFirstFile(), FindNextFile() to get the files. For showing the folder icons in list control you will have to create a custom list control.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
For two section of your question do you need to SHGetFileInfo
|
|
|
|
|
i can get all the files and folders but i dont know how to list them in the list view control with the icons
|
|
|
|
|
You must try like this
LV_ITEM LItem2 ={0};
m_pImageList2->Add(Bmp,RGB(100,105,0));
m_ListFile2.SetImageList(m_pImageList2, LVSIL_NORMAL);
LItem2 .mask = LVIF_TEXT| LVIF_IMAGE| LVIF_STATE;
LItem2 .iItem =Item;
LItem2 .iSubItem = 0;
LItem2 .pszText = lpt;
LItem2 .iImage = Item;
LItem2 .stateMask = LVIS_STATEIMAGEMASK;
LItem2 .state = INDEXTOSTATEIMAGEMASK(1);
m_ListFile2.InsertItem( &LItem2);
But I suggest see ListControl section on the codeproject for get full information;)
|
|
|
|