Check if only one string variable is not nullptr in C++

Viewed 2791

I have three LPCWSTR string variables called A, B, C.

I am assigning them from another function which can sometimes return nullptr if something goes wrong. like this:

A = MyFunc();
B = MyFunc();
C = MyFunc();

Now, for some stuff with those variables, I need to check if only one of these variables is not nullptr(only one of variables is assigned).

I tried to do this myself like:

if ((A == nullptr) && (B == nullptr) && (C <> nullptr)) {}

Any ideas about how to do this are welcome.

5 Answers
Related