tags:

views:

70

answers:

2

Is this

if( (FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
    (wcscmp(FileData.cFileName, L".") != 0) &&
    (wcscmp(FileData.cFileName, L"..") != 0) )

the same as this:

if( (FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
    wcscmp(FileData.cFileName, L".") &&
    wcscmp(FileData.cFileName, L"..") )

And also if you use strcmp instead of wcscmp? It should check equality (strict) of the name with ".." and "." (directory search).

Thanks!

+3  A: 

If I'm not mistaken, both examples do the same thing.

LukeN
I second you...
Praveen S
+1  A: 

In C, "true" is defined as "not zero". "false" is defined as "zero". So yes, they're the same.

Do be careful about methods that return non-primitive types, though; in C++, operator overloading could make "!= 0" not actually compare something with zero :-P. Not a problem here, though.

Also, if you don't put in the parentheses, make sure you understand the order of operations.

Borealid