I am quite stumped on something in C. I found this code on the Internet, and it only gives me one error; however, I cannot seem to fix it. The variable in the function the compiler's complaining about is:

char ConvertTime[8]

and the function itself is a windows one:

GetWindowTextW(GETITEM(IDC_CONVERT_TIME), ConvertTime, 9);

Apparently it has something to do with LPWSTR. I'm not experienced in this realm, so I am asking nicely for help. Thanks in advance for any reply.

Recommended Answers

All 6 Replies

The function you are calling is UNICODE function. LPWSTR is a pointer to a unicode string, not an ascii string. You need to declare the string like this: wchar_t ConvertTime[9]; , or if you want to compile the program as either ascii or unicode then use the macro TCHAR: TCHAR ConvertTime[9]; and include <tchar.h> header file.

the thing about that is, later on down the road, there's a strncpy() function that doesn't like either method.

tchar.h contains macros that can be used to treat standard c functions as either ascii or unicode, depending on how the program is written. If you replace strncpy() with _tscncpy() it will compile correctly either way. Read that article carefully and it will explain why, and give you an example. There are links at the bottom to other string manipulation functions.

I did everything recommended plus some but one other function that I have no idea what it is that it's complaining about:


very funny. i need a tchar.h substitute for it. I know what it is.

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.