Dark Bit Factory & Gravity
PROGRAMMING => C / C++ /C# => Topic started by: Shockwave on March 08, 2007
-
Huh?
I get this error;
1>.\Hullo.cpp(6) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [5]' to 'LPCWSTR'
Here is the source...
#include <IOSTREAM>
#include <WINDOWS.H>
int main()
{
MessageBox (0, "text" ,"caption", 0);
std::cout << "Hello World\n";
return 0;
}
Which looks okay to me..
It compiles and runs ok without ;
MessageBox (0, "text" ,"caption", 0);
-
This could be an unicode / ansi related problem. Try this instead :
#include <IOSTREAM>
#include <WINDOWS.H>
int main()
{
MessageBox (0, TEXT("text") ,TEXT("caption"), 0);
std::cout << "Hello World\n";
return 0;
}
-
Because I have been so frustrated by this and so stressed out I am very grateful to you.
Basically you've done a lot to fix my problems so what can I say?
As an admin of the forum, Karma is easy for me to give, but what you need to know is that you have given me confidence that my C++ installation now works, so what I decided to do was remove some of my own Karma and give it to you and rbraz, all my Karma has been awarded in good faith by people and I think it will show you how greatful I am.
Thank you Benny. And Thanks to Rbraz for the api example.
-
Wow shocky, that's very kind. Thanks a lot for that outstanding karma boost.
I am glad if I could helped you. C++ is very frustrating especially in the beginning.
So, good luck for your further steps with C++. I am of course willing to help where
I can...
K++ for such a nice gesture ;)
-
Shockwave, your original code worked fine for me in dev c++
-
Thanks Paul :)
You would not believe the hassles I had setting up Visual Studio.. People tell me it's worth it though!
-
I installed the express version but i kinda like dev
-
I prefer dev, it produces executables like .5k larger but it has string libraries by default to avoid problems like this.
-
After driving a delivery van for too many years and learning all the wrong languages, the whole commercial world seems to use M$ so as much as I hate it, I suppose I should learn this.
-
After driving a delivery van for too many years and learning all the wrong languages, the whole commercial world seems to use M$ so as much as I hate it, I suppose I should learn this.
Right. I guess, if you decide to learn C++ in the M$-World, I also would suggest to
go with the Visual Suite. In addition, remember that you can use the IDE for mulitple
purposes (C#, .NET and so on....)
-
This could be an unicode / ansi related problem. Try this instead :
#include <IOSTREAM>
#include <WINDOWS.H>
int main()
{
MessageBox (0, TEXT("text") ,TEXT("caption"), 0);
std::cout << "Hello World\n";
return 0;
}
Yup, definitely this is a problem with unicode X ansi, to fix this, go to "Project" Properties -> Configurations Properties -> General -> Character Set -> and select "Not Set"
-
Thanks Rbraz, question, do I need to do this for every project?
-
I had the exact same problem when I first tried to make a program in VS too ^^, hadnt read this post till now though, your not alone :D
-
Thanks Rbraz, question, do I need to do this for every project?
There's a way to modify this default option.
Find the file: default.js located in ..\Microsoft Visual Studio 8\VC\VCWizards\AppWiz\Generic\Application\scripts\1033
Open it with notepad (don't forget to make a backup copy of default.js), search for this line:
config.CharacterSet = charSetUNICODE;
and change it to:
config.CharacterSet = charSetNotSet;
Now your default option for character set will be always "not set" (Ansi)
-
Thanks Rbraz :)
-
That one caught me out too, for a bit :). Microsoft changed the default character size to 16bit unicode between VS2003 and VS2005.
Another way round it is to add
#undef UNICODEas the very first line of your source, but it's better to change it in the options.
Jim