0

Hello,
I want to convert a WORD type to a string, I have this code:

FileTimeToSystemTime(&fdFile.ftLastWriteTime, &SysTime);
String numday = SysTime.wDay;

But i says that operation connot be done because it's a WORD what I wan to insert to a String.

And my question is, is there any function/way to convert a WORD to string?

Thanks!

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by Schol-R-LEA
0

A WORD value is a 16-bit unsigned integer type used in Windows. Since it is actually only a typedef of unsigned short under the current Microsoft VC++ library, Assuming you are using standard C++ strings, it should be possible to use an stringstream to convert it to a string.

std::stringstream convert;
std::string numday;

convert << SysTime.wDay;
convert >> numday;

I cannot guarantee that this will work using other compilers, however.

Now, I noted that you have the type of numday as String, (note the capitalization), which is not the same as the standard string class. Was this a typo, or are you actually using a different string class?

Edited by Schol-R-LEA

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.