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!

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.