I am relatively new to C++ and am currently taking a course for it. One of my assignments is to make a calculator for hourly wages and figure gross and net pay based on a fixed percentage for taxes.

I am able to compile the code if I change the default character set from unicode to not used, but my professor is saying I have bad code. While it does compile with unicode turned off, I still get runtime errors that can be ignored during program execution. Also, if I use the same code in dev-C++ I do not have any issues.

I am using Visual Studio 2008 and have gone over the syntax with my book for hours and hours with the same results. I am getting errors while converting from const to char[x] to LPCWSTR. Any help, or even an explanation of the errors would be greatly appreciated!

LINE 2 error C2440: '=' : cannot convert from 'const char [9]' to 'LPCWSTR'

	wc.lpszClassName = "PayClass";

LINE 12 error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [9]' to 'LPCWSTR'

hWnd = CreateWindow(

Edited 7 Years Ago by aszopinski: Added details

You need to turn off UNICODE. Go to menu Project --> Properties (last item in the menu), Configuration Properties --> General. Then change "Character Set" (3d from bottom on the right) to "Not Set".

Either that or use UNICODE string literals, such as _TEXT("Some string literal")

Edited 7 Years Ago by Ancient Dragon: n/a

Use the _T macro, which will automatically convert literal strings to the appropriate type (Unicode or MBCS), based on the build type.

In short, a good thing to do: Always enclose literal strings in the program within the _T macro.

For example:

SomeAPICall(_T("Some literal string"));

See Unicode Programming Summary.

This question has already been answered. Start a new discussion instead.