Using ternary operator in c++ returns false condition always [duplicate] The Next CEO of Stack OverflowHow to compare two BSTRs or CComBSTRs?How to compare BSTR against a string in c/c++?C++ string literal equality check?What is the “-->” operator in C++?Boolean variables aren't always false by default?Ternary conditional and assignment operator precedenceReturn type of '?:' (ternary conditional operator)Replacing a 32-bit loop counter with 64-bit introduces crazy performance deviationsIs the operation “false < true” well defined?C++ comparison operator not returning true or falseWhy does the ternary operator with commas evaluate only one expression in the true case?Does the C++ standard allow for an uninitialized bool to crash a program?Why and when does the ternary operator return an lvalue?

Why is quantifier elimination desirable for a given theory?

Is it my responsibility to learn a new technology in my own time my employer wants to implement?

Reference request: Grassmannian and Plucker coordinates in type B, C, D

Does increasing your ability score affect your main stat?

Break Away Valves for Launch

Domestic-to-international connection at Orlando (MCO)

Is it possible to replace duplicates of a character with one character using tr

Why is information "lost" when it got into a black hole?

Why do airplanes bank sharply to the right after air-to-air refueling?

No sign flipping while figuring out the emf of voltaic cell?

Are police here, aren't itthey?

Would a completely good Muggle be able to use a wand?

Is micro rebar a better way to reinforce concrete than rebar?

Why doesn't UK go for the same deal Japan has with EU to resolve Brexit?

Why, when going from special to general relativity, do we just replace partial derivatives with covariant derivatives?

Flying from Cape Town to England and return to another province

Why is my new battery behaving weirdly?

What does "Its cash flow is deeply negative" mean?

Why don't programming languages automatically manage the synchronous/asynchronous problem?

I want to delete every two lines after 3rd lines in file contain very large number of lines :

How to install OpenCV on Raspbian Stretch?

Solving system of ODEs with extra parameter

Running a General Election and the European Elections together

How a 64-bit process virtual address space is divided in Linux?



Using ternary operator in c++ returns false condition always [duplicate]



The Next CEO of Stack OverflowHow to compare two BSTRs or CComBSTRs?How to compare BSTR against a string in c/c++?C++ string literal equality check?What is the “-->” operator in C++?Boolean variables aren't always false by default?Ternary conditional and assignment operator precedenceReturn type of '?:' (ternary conditional operator)Replacing a 32-bit loop counter with 64-bit introduces crazy performance deviationsIs the operation “false < true” well defined?C++ comparison operator not returning true or falseWhy does the ternary operator with commas evaluate only one expression in the true case?Does the C++ standard allow for an uninitialized bool to crash a program?Why and when does the ternary operator return an lvalue?










-2
















This question already has an answer here:



  • How to compare two BSTRs or CComBSTRs?

    3 answers



I am using a statement with ternary operator which is always returning the other value.



BSTR pVal = L"Yes";

bool val = pVal == L"Yes" ? true : false;


this statement returns



 val = false;


I expect it to return true here. Am i making it wrong?










share|improve this question













marked as duplicate by πάντα ῥεῖ c++
Users with the  c++ badge can single-handedly close c++ questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 21 at 17:58


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • BSTR types cannot be compared directly using ==.

    – πάντα ῥεῖ
    Mar 21 at 17:57






  • 2





    Unrelated to your issue, but this is not a valid way to create a BSTR. They're supposed to be allocated with SysAllocString. In C++ it's best to use a wrapper type like _bstr_t, which will also solve your comparison issues.

    – interjay
    Mar 21 at 17:59












  • How to compare BSTR against a string

    – R Sahu
    Mar 21 at 18:00











  • Not a bug, but a == b ? true : false is usually written a == b.

    – molbdnilo
    Mar 21 at 18:08















-2
















This question already has an answer here:



  • How to compare two BSTRs or CComBSTRs?

    3 answers



I am using a statement with ternary operator which is always returning the other value.



BSTR pVal = L"Yes";

bool val = pVal == L"Yes" ? true : false;


this statement returns



 val = false;


I expect it to return true here. Am i making it wrong?










share|improve this question













marked as duplicate by πάντα ῥεῖ c++
Users with the  c++ badge can single-handedly close c++ questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 21 at 17:58


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • BSTR types cannot be compared directly using ==.

    – πάντα ῥεῖ
    Mar 21 at 17:57






  • 2





    Unrelated to your issue, but this is not a valid way to create a BSTR. They're supposed to be allocated with SysAllocString. In C++ it's best to use a wrapper type like _bstr_t, which will also solve your comparison issues.

    – interjay
    Mar 21 at 17:59












  • How to compare BSTR against a string

    – R Sahu
    Mar 21 at 18:00











  • Not a bug, but a == b ? true : false is usually written a == b.

    – molbdnilo
    Mar 21 at 18:08













-2












-2








-2









This question already has an answer here:



  • How to compare two BSTRs or CComBSTRs?

    3 answers



I am using a statement with ternary operator which is always returning the other value.



BSTR pVal = L"Yes";

bool val = pVal == L"Yes" ? true : false;


this statement returns



 val = false;


I expect it to return true here. Am i making it wrong?










share|improve this question















This question already has an answer here:



  • How to compare two BSTRs or CComBSTRs?

    3 answers



I am using a statement with ternary operator which is always returning the other value.



BSTR pVal = L"Yes";

bool val = pVal == L"Yes" ? true : false;


this statement returns



 val = false;


I expect it to return true here. Am i making it wrong?





This question already has an answer here:



  • How to compare two BSTRs or CComBSTRs?

    3 answers







c++






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 21 at 17:54









S.Frank RicharrdS.Frank Richarrd

1049




1049




marked as duplicate by πάντα ῥεῖ c++
Users with the  c++ badge can single-handedly close c++ questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 21 at 17:58


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by πάντα ῥεῖ c++
Users with the  c++ badge can single-handedly close c++ questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 21 at 17:58


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • BSTR types cannot be compared directly using ==.

    – πάντα ῥεῖ
    Mar 21 at 17:57






  • 2





    Unrelated to your issue, but this is not a valid way to create a BSTR. They're supposed to be allocated with SysAllocString. In C++ it's best to use a wrapper type like _bstr_t, which will also solve your comparison issues.

    – interjay
    Mar 21 at 17:59












  • How to compare BSTR against a string

    – R Sahu
    Mar 21 at 18:00











  • Not a bug, but a == b ? true : false is usually written a == b.

    – molbdnilo
    Mar 21 at 18:08

















  • BSTR types cannot be compared directly using ==.

    – πάντα ῥεῖ
    Mar 21 at 17:57






  • 2





    Unrelated to your issue, but this is not a valid way to create a BSTR. They're supposed to be allocated with SysAllocString. In C++ it's best to use a wrapper type like _bstr_t, which will also solve your comparison issues.

    – interjay
    Mar 21 at 17:59












  • How to compare BSTR against a string

    – R Sahu
    Mar 21 at 18:00











  • Not a bug, but a == b ? true : false is usually written a == b.

    – molbdnilo
    Mar 21 at 18:08
















BSTR types cannot be compared directly using ==.

– πάντα ῥεῖ
Mar 21 at 17:57





BSTR types cannot be compared directly using ==.

– πάντα ῥεῖ
Mar 21 at 17:57




2




2





Unrelated to your issue, but this is not a valid way to create a BSTR. They're supposed to be allocated with SysAllocString. In C++ it's best to use a wrapper type like _bstr_t, which will also solve your comparison issues.

– interjay
Mar 21 at 17:59






Unrelated to your issue, but this is not a valid way to create a BSTR. They're supposed to be allocated with SysAllocString. In C++ it's best to use a wrapper type like _bstr_t, which will also solve your comparison issues.

– interjay
Mar 21 at 17:59














How to compare BSTR against a string

– R Sahu
Mar 21 at 18:00





How to compare BSTR against a string

– R Sahu
Mar 21 at 18:00













Not a bug, but a == b ? true : false is usually written a == b.

– molbdnilo
Mar 21 at 18:08





Not a bug, but a == b ? true : false is usually written a == b.

– molbdnilo
Mar 21 at 18:08












1 Answer
1






active

oldest

votes


















5














A lot here is wrong.



== on BSTR compares pointer values. Two L"Yes" being pointer-equal is implementation defined.



bool_expr?true:false is a noop.



bool val = wcscmp(pVal, L"Yes") == 0;


is probably what you want.



BSTR pVal = L"Yes";


is bad news; that isn't how you are supposed to create a BSTR. BSTR are supposed to be pascal-esque strings allocated in a specific region of memory.



BSTR pVal = SysAllocString(L"Yes");


is usually better.



Using wcscmp is valid on a BSTR, as BSTR is guaranteed null terminated. But assigning a null terminated string to a BSTR is not a good plan; the code consuming the BSTR may expect the length field to come before the first character.



It may even be a good plan to use _bstr_t which is a C++ wrapper around BSTR.



It is also usually a good idea to compare BSTR to BSTR and not using C APIs; a BSTR can contain embedded NULs, and C APIs stop at the first NUL.



_bstr_t pVal = L"Yes";

bool val = pVal == _bstr_t(L"Yes");


_bstr_t has an operator== that does a reasonable thing.






share|improve this answer

























  • bstr_t is a completely diferent type than wide string, one need to use the (Windows) OS conversion functions to convert one into another.

    – πάντα ῥεῖ
    Mar 21 at 18:00











  • @πάνταῥεῖ Not completely different (you can use wcscmp), but yes, I added that.

    – Yakk - Adam Nevraumont
    Mar 21 at 18:03






  • 1





    You cannot safely use the C string functions. BSTRs can contain embedded NUL characters. They are Pascal-style strings, with the length stored inside the string. Not C-style strings with sentinel terminator characters.

    – Cody Gray♦
    Mar 21 at 18:09











  • @CodyGray Part of that depends on what you want == to do, but yes, probably wrapping the other L"Yes" in a BSTR and using BSTR-approved comparisons is a good plan. On the other hand, I can guarantee I can find an issue with every single == on two strings; there are languages where multiple characters become fewer in other cases, combinations of characters codes that can be treated identically or not with other characters, etc.

    – Yakk - Adam Nevraumont
    Mar 21 at 18:15











  • Yeah, just to be clear, it wasn't a criticism of your answer so much as a response to your discussion with πάντα in the comments. In this very limited case, where you're comparing to a string literal, it would obviously be fine to use wcscmp. I just wanted to explain why it's not a valid approach in general.

    – Cody Gray♦
    Mar 21 at 20:38


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









5














A lot here is wrong.



== on BSTR compares pointer values. Two L"Yes" being pointer-equal is implementation defined.



bool_expr?true:false is a noop.



bool val = wcscmp(pVal, L"Yes") == 0;


is probably what you want.



BSTR pVal = L"Yes";


is bad news; that isn't how you are supposed to create a BSTR. BSTR are supposed to be pascal-esque strings allocated in a specific region of memory.



BSTR pVal = SysAllocString(L"Yes");


is usually better.



Using wcscmp is valid on a BSTR, as BSTR is guaranteed null terminated. But assigning a null terminated string to a BSTR is not a good plan; the code consuming the BSTR may expect the length field to come before the first character.



It may even be a good plan to use _bstr_t which is a C++ wrapper around BSTR.



It is also usually a good idea to compare BSTR to BSTR and not using C APIs; a BSTR can contain embedded NULs, and C APIs stop at the first NUL.



_bstr_t pVal = L"Yes";

bool val = pVal == _bstr_t(L"Yes");


_bstr_t has an operator== that does a reasonable thing.






share|improve this answer

























  • bstr_t is a completely diferent type than wide string, one need to use the (Windows) OS conversion functions to convert one into another.

    – πάντα ῥεῖ
    Mar 21 at 18:00











  • @πάνταῥεῖ Not completely different (you can use wcscmp), but yes, I added that.

    – Yakk - Adam Nevraumont
    Mar 21 at 18:03






  • 1





    You cannot safely use the C string functions. BSTRs can contain embedded NUL characters. They are Pascal-style strings, with the length stored inside the string. Not C-style strings with sentinel terminator characters.

    – Cody Gray♦
    Mar 21 at 18:09











  • @CodyGray Part of that depends on what you want == to do, but yes, probably wrapping the other L"Yes" in a BSTR and using BSTR-approved comparisons is a good plan. On the other hand, I can guarantee I can find an issue with every single == on two strings; there are languages where multiple characters become fewer in other cases, combinations of characters codes that can be treated identically or not with other characters, etc.

    – Yakk - Adam Nevraumont
    Mar 21 at 18:15











  • Yeah, just to be clear, it wasn't a criticism of your answer so much as a response to your discussion with πάντα in the comments. In this very limited case, where you're comparing to a string literal, it would obviously be fine to use wcscmp. I just wanted to explain why it's not a valid approach in general.

    – Cody Gray♦
    Mar 21 at 20:38
















5














A lot here is wrong.



== on BSTR compares pointer values. Two L"Yes" being pointer-equal is implementation defined.



bool_expr?true:false is a noop.



bool val = wcscmp(pVal, L"Yes") == 0;


is probably what you want.



BSTR pVal = L"Yes";


is bad news; that isn't how you are supposed to create a BSTR. BSTR are supposed to be pascal-esque strings allocated in a specific region of memory.



BSTR pVal = SysAllocString(L"Yes");


is usually better.



Using wcscmp is valid on a BSTR, as BSTR is guaranteed null terminated. But assigning a null terminated string to a BSTR is not a good plan; the code consuming the BSTR may expect the length field to come before the first character.



It may even be a good plan to use _bstr_t which is a C++ wrapper around BSTR.



It is also usually a good idea to compare BSTR to BSTR and not using C APIs; a BSTR can contain embedded NULs, and C APIs stop at the first NUL.



_bstr_t pVal = L"Yes";

bool val = pVal == _bstr_t(L"Yes");


_bstr_t has an operator== that does a reasonable thing.






share|improve this answer

























  • bstr_t is a completely diferent type than wide string, one need to use the (Windows) OS conversion functions to convert one into another.

    – πάντα ῥεῖ
    Mar 21 at 18:00











  • @πάνταῥεῖ Not completely different (you can use wcscmp), but yes, I added that.

    – Yakk - Adam Nevraumont
    Mar 21 at 18:03






  • 1





    You cannot safely use the C string functions. BSTRs can contain embedded NUL characters. They are Pascal-style strings, with the length stored inside the string. Not C-style strings with sentinel terminator characters.

    – Cody Gray♦
    Mar 21 at 18:09











  • @CodyGray Part of that depends on what you want == to do, but yes, probably wrapping the other L"Yes" in a BSTR and using BSTR-approved comparisons is a good plan. On the other hand, I can guarantee I can find an issue with every single == on two strings; there are languages where multiple characters become fewer in other cases, combinations of characters codes that can be treated identically or not with other characters, etc.

    – Yakk - Adam Nevraumont
    Mar 21 at 18:15











  • Yeah, just to be clear, it wasn't a criticism of your answer so much as a response to your discussion with πάντα in the comments. In this very limited case, where you're comparing to a string literal, it would obviously be fine to use wcscmp. I just wanted to explain why it's not a valid approach in general.

    – Cody Gray♦
    Mar 21 at 20:38














5












5








5







A lot here is wrong.



== on BSTR compares pointer values. Two L"Yes" being pointer-equal is implementation defined.



bool_expr?true:false is a noop.



bool val = wcscmp(pVal, L"Yes") == 0;


is probably what you want.



BSTR pVal = L"Yes";


is bad news; that isn't how you are supposed to create a BSTR. BSTR are supposed to be pascal-esque strings allocated in a specific region of memory.



BSTR pVal = SysAllocString(L"Yes");


is usually better.



Using wcscmp is valid on a BSTR, as BSTR is guaranteed null terminated. But assigning a null terminated string to a BSTR is not a good plan; the code consuming the BSTR may expect the length field to come before the first character.



It may even be a good plan to use _bstr_t which is a C++ wrapper around BSTR.



It is also usually a good idea to compare BSTR to BSTR and not using C APIs; a BSTR can contain embedded NULs, and C APIs stop at the first NUL.



_bstr_t pVal = L"Yes";

bool val = pVal == _bstr_t(L"Yes");


_bstr_t has an operator== that does a reasonable thing.






share|improve this answer















A lot here is wrong.



== on BSTR compares pointer values. Two L"Yes" being pointer-equal is implementation defined.



bool_expr?true:false is a noop.



bool val = wcscmp(pVal, L"Yes") == 0;


is probably what you want.



BSTR pVal = L"Yes";


is bad news; that isn't how you are supposed to create a BSTR. BSTR are supposed to be pascal-esque strings allocated in a specific region of memory.



BSTR pVal = SysAllocString(L"Yes");


is usually better.



Using wcscmp is valid on a BSTR, as BSTR is guaranteed null terminated. But assigning a null terminated string to a BSTR is not a good plan; the code consuming the BSTR may expect the length field to come before the first character.



It may even be a good plan to use _bstr_t which is a C++ wrapper around BSTR.



It is also usually a good idea to compare BSTR to BSTR and not using C APIs; a BSTR can contain embedded NULs, and C APIs stop at the first NUL.



_bstr_t pVal = L"Yes";

bool val = pVal == _bstr_t(L"Yes");


_bstr_t has an operator== that does a reasonable thing.







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 21 at 18:17

























answered Mar 21 at 17:58









Yakk - Adam NevraumontYakk - Adam Nevraumont

188k21199384




188k21199384












  • bstr_t is a completely diferent type than wide string, one need to use the (Windows) OS conversion functions to convert one into another.

    – πάντα ῥεῖ
    Mar 21 at 18:00











  • @πάνταῥεῖ Not completely different (you can use wcscmp), but yes, I added that.

    – Yakk - Adam Nevraumont
    Mar 21 at 18:03






  • 1





    You cannot safely use the C string functions. BSTRs can contain embedded NUL characters. They are Pascal-style strings, with the length stored inside the string. Not C-style strings with sentinel terminator characters.

    – Cody Gray♦
    Mar 21 at 18:09











  • @CodyGray Part of that depends on what you want == to do, but yes, probably wrapping the other L"Yes" in a BSTR and using BSTR-approved comparisons is a good plan. On the other hand, I can guarantee I can find an issue with every single == on two strings; there are languages where multiple characters become fewer in other cases, combinations of characters codes that can be treated identically or not with other characters, etc.

    – Yakk - Adam Nevraumont
    Mar 21 at 18:15











  • Yeah, just to be clear, it wasn't a criticism of your answer so much as a response to your discussion with πάντα in the comments. In this very limited case, where you're comparing to a string literal, it would obviously be fine to use wcscmp. I just wanted to explain why it's not a valid approach in general.

    – Cody Gray♦
    Mar 21 at 20:38


















  • bstr_t is a completely diferent type than wide string, one need to use the (Windows) OS conversion functions to convert one into another.

    – πάντα ῥεῖ
    Mar 21 at 18:00











  • @πάνταῥεῖ Not completely different (you can use wcscmp), but yes, I added that.

    – Yakk - Adam Nevraumont
    Mar 21 at 18:03






  • 1





    You cannot safely use the C string functions. BSTRs can contain embedded NUL characters. They are Pascal-style strings, with the length stored inside the string. Not C-style strings with sentinel terminator characters.

    – Cody Gray♦
    Mar 21 at 18:09











  • @CodyGray Part of that depends on what you want == to do, but yes, probably wrapping the other L"Yes" in a BSTR and using BSTR-approved comparisons is a good plan. On the other hand, I can guarantee I can find an issue with every single == on two strings; there are languages where multiple characters become fewer in other cases, combinations of characters codes that can be treated identically or not with other characters, etc.

    – Yakk - Adam Nevraumont
    Mar 21 at 18:15











  • Yeah, just to be clear, it wasn't a criticism of your answer so much as a response to your discussion with πάντα in the comments. In this very limited case, where you're comparing to a string literal, it would obviously be fine to use wcscmp. I just wanted to explain why it's not a valid approach in general.

    – Cody Gray♦
    Mar 21 at 20:38

















bstr_t is a completely diferent type than wide string, one need to use the (Windows) OS conversion functions to convert one into another.

– πάντα ῥεῖ
Mar 21 at 18:00





bstr_t is a completely diferent type than wide string, one need to use the (Windows) OS conversion functions to convert one into another.

– πάντα ῥεῖ
Mar 21 at 18:00













@πάνταῥεῖ Not completely different (you can use wcscmp), but yes, I added that.

– Yakk - Adam Nevraumont
Mar 21 at 18:03





@πάνταῥεῖ Not completely different (you can use wcscmp), but yes, I added that.

– Yakk - Adam Nevraumont
Mar 21 at 18:03




1




1





You cannot safely use the C string functions. BSTRs can contain embedded NUL characters. They are Pascal-style strings, with the length stored inside the string. Not C-style strings with sentinel terminator characters.

– Cody Gray♦
Mar 21 at 18:09





You cannot safely use the C string functions. BSTRs can contain embedded NUL characters. They are Pascal-style strings, with the length stored inside the string. Not C-style strings with sentinel terminator characters.

– Cody Gray♦
Mar 21 at 18:09













@CodyGray Part of that depends on what you want == to do, but yes, probably wrapping the other L"Yes" in a BSTR and using BSTR-approved comparisons is a good plan. On the other hand, I can guarantee I can find an issue with every single == on two strings; there are languages where multiple characters become fewer in other cases, combinations of characters codes that can be treated identically or not with other characters, etc.

– Yakk - Adam Nevraumont
Mar 21 at 18:15





@CodyGray Part of that depends on what you want == to do, but yes, probably wrapping the other L"Yes" in a BSTR and using BSTR-approved comparisons is a good plan. On the other hand, I can guarantee I can find an issue with every single == on two strings; there are languages where multiple characters become fewer in other cases, combinations of characters codes that can be treated identically or not with other characters, etc.

– Yakk - Adam Nevraumont
Mar 21 at 18:15













Yeah, just to be clear, it wasn't a criticism of your answer so much as a response to your discussion with πάντα in the comments. In this very limited case, where you're comparing to a string literal, it would obviously be fine to use wcscmp. I just wanted to explain why it's not a valid approach in general.

– Cody Gray♦
Mar 21 at 20:38






Yeah, just to be clear, it wasn't a criticism of your answer so much as a response to your discussion with πάντα in the comments. In this very limited case, where you're comparing to a string literal, it would obviously be fine to use wcscmp. I just wanted to explain why it's not a valid approach in general.

– Cody Gray♦
Mar 21 at 20:38






Popular posts from this blog

How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?