C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 08-08-2007, 09:51 AM   #1
Registered User
 
Join Date: Jul 2007
Posts: 11
Visual Studio Express 2008 problems.

I'm trying to use the compiler Visual Studio Express 2008, yet a sample program that worked for Dev C++ and is supposed to work with VC++.

http://www.winprog.org/tutorial/simple_window.html.

I've just copy pasted to get around any mistypes, but i keep getting 4 errors:

.\first_vc.cpp(40) : error C2440: '=' : cannot convert from 'const char [14]' to 'LPCWSTR'
.\first_vc.cpp(46) : error C2664: 'MessageBox' : cannot convert parameter 2 from 'const char [28]' to 'LPCTSTR'
.\first_vc.cpp(57) : error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [14]' to 'LPCWSTR'
.\first_vc.cpp(61) : error C2440: 'initializing' : cannot convert from 'const char [24]' to 'LPCTSTR'
.\first_vc.cpp(63) : error C2664: 'MessageBox' : cannot convert parameter 3 from 'const char [7]' to 'LPCTSTR'

there seems to be some kind of conversion error like VC++ can't handle Char's.

Thanks for any help
Normac is offline   Reply With Quote
Old 08-08-2007, 09:58 AM   #2
System Novice
 
siavoshkc's Avatar
 
Join Date: Jan 2006
Location: Tehran
Posts: 1,074
It is because you should use unicode. But you are using ASCII. You may change its settings.
[edit] Use wchar_t[/edit]
__________________
Microsoft Visual Studio 2008 Professional (On Microsoft Windows XP SP2)

Learn the language before using it. (C++ Books and C Books)
Read the FAQ before making a problem.
Then make a Google and Forum search.

My code painter new version Version 0.97 DOWNLOAD NOW! (Let the pop up, pop!)

SiavoshKC
siavoshkc is offline   Reply With Quote
Old 08-08-2007, 10:41 AM   #3
and the hat of vanishing
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,214
See http://msdn2.microsoft.com/en-us/lib...tz(VS.80).aspx

Rather than
char message[] = "hello";

You would say
_TCHAR message[] = _TEXT("hello"); // _T() is a shorter macro for _TEXT()

Or
printf("hello");
would be
_tprintf(_T("hello"));

If you use these macros correctly, then your code will compile in ASCII or UNICODE mode.
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Up to 8Mb PlusNet broadband from only £5.99 a month!
Salem is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
sorting the matrix question.. transgalactic2 C Programming 47 12-22-2008 03:17 PM
Avoiding Global variables csonx_p Windows Programming 32 05-19-2008 12:17 AM
Crazy errors caused by class, never seen before.. Shamino C++ Programming 2 06-10-2007 11:54 AM
Compiling from DOS Prompt using Visual Studio Express 2005 The SharK C++ Programming 8 06-13-2006 01:24 AM
Using 'if' with char arrays or string objects c++_n00b C++ Programming 36 06-06-2002 09:04 PM


All times are GMT -6. The time now is 04:35 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22