开发者

strcmp and wcscmp

Is this

if( (FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &a开发者_StackOverflowmp;&
    (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!


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜