0

I'm writing a response to a WCF call in unmanaged code. The problem is that I have an integer which I want to convert into WS_STRING and respond back.

The std::towstring converts only to a wstring and doesn't convert into WS_STRING. How can I make that happen ?

I saw there was an older thread that had a similar question, but it seemed unanswered.

int i = 100;
responseWsString = std::to_wstring(i);
//Throws compiler error : No operator '=' matches operands of type WS_STRING = std::wstring

This is expected as the types are differnt. The other thread mentions that const_cast<> is not a good approach. Then how do I solve this simple problem to convert int into WS_STRING ?

Here is a link to the previous: Convert wstring to WS_STRING

Community
  • 1
  • 1
confusednerd
  • 138
  • 3
  • 17

1 Answers1

1

This answer already shows how to convert a std::wstring into a WS_STRING.

You already know how to convert a number into std::wstring:

int i = 100;
std::wstring iStr = std::to_wstring(i);

So it's just a matter of using the iStr as input for the solution provided in the linked answer.

Hint: Replace d by iStr, replace url by responseWsString.

Community
  • 1
  • 1
zett42
  • 25,437
  • 3
  • 35
  • 72