Visual Studio Express 2008 problems.

This is a discussion on Visual Studio Express 2008 problems. within the C++ Programming forums, part of the General Programming Boards category; I'm trying to use the compiler Visual Studio Express 2008, yet a sample program that worked for Dev C++ and ...

  1. #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

  2. #2
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,236
    It is because you should use unicode. But you are using ASCII. You may change its settings.
    [edit] Use wchar_t[/edit]
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,761
    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.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

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

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