<<Everytime I paste a code copied somewhere i found in internet it always getting error, i compile but seems it really doesnt want to work with me
i have version 4.9.9.2 by bloodshed
i was trying to make just a simple hello world with this code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <windows.h> // include the basic windows header file
// the entry point for any Windows program
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd)
{
// create a "Hello World" message box using MessageBox()
MessageBox(NULL,
L"Hello World!",
L"Just another Hello World program!",
MB_ICONEXCLAMATION | MB_OK);
// return 0 to Windows
return 0;
}
and it always show me this message:
1 2
In function `int WinMain(HINSTANCE__*, HINSTANCE__*, CHAR*, int)':
cannot convert `const wchar_t*' to `const CHAR*' for argument `2' to `int MessageBoxA(HWND__*, const CHAR*, const CHAR*, UINT)'
anyone can tell me what should i change to be compatible with my C++>>
Try deleting those L's before your strings. What are they for, anyway?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <windows.h> // include the basic windows header file
// the entry point for any Windows program
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd)
{
// create a "Hello World" message box using MessageBox()
MessageBox(NULL,
"Hello World!",
"Just another Hello World program!",
MB_ICONEXCLAMATION | MB_OK);
// return 0 to Windows
return 0;
}
hmm i was searching for a code for C++ for my activity which create a graphics in my program to make it more interesting but surfing, i was lead to http://www.directxtutorial.com/index.aspx and i was attracted by its topic and when i saw that code i think how bout if i try it then i conclude with an error that took me a lot of time =\
anyway as i remember would you kindly gave me a simple just a simple code that gave a graphic animation in C++ plzzzz
The L's are needed because it indicates that the strings are of wide strings. Wide strings are actually required in the MessageBox function. If you use c-style strings, the compiler will complain about it. Optionally, you can also use the TEXT() macro.
TEXT("My String")
@senatin:
I see no problem in your code. I even compiled it on my machine to test it and I can make the MessageBox appear.
I have never tried bloodshed, as I am using Visual Studio C++.
I would try changing the "L" literal for your wide strings to TEXT(""); see if that works.
what magicalblender said was true
it work
but i try your way too thanks
TEXT("");or TEXT(""),
it wont work for me
as i think of now is it possible that i can insert this program to my already existing code activity?
I was thinking if it possible that in the end of my activity's output this windows then appear!! is it possible?
I need a graphic demonstration please anyone!!!
I saw a program with such thing and also with sound but i dont know who did it!
Uh, it is not my way. I learned that TEXT() macro from Charles Petzold's book. And like I said, I used Visual Studio C++ to compile your original code (the one with "L" literals), not Bloodshed so it's just a compiler issue.
It depends on how you integrate programs. If you are integrating a windows application program and a windows console program, then I am not sure if it will work. But technically speaking, most of the codes you'll see inside a windows application program will be pretty much the same as a windows console program with just more macros and function calls.
As for the graphics part of windows programming, I suggest you get started on understanding how to register and show your window first. If you do not have a main window, then you won't get a client area to display the graphics. If you can do MessageBox, then showing the main window is a little step further.
After you can show the main window, you move on to message processing. Define your WndProc and make sure you understand how messages are handled. Once you get to know those basics, it'll be easier to answer more specific questions regarding graphics.
about the windows programming.
i really appreciate what you suggested but I need a code note including windows cause of circumstances(Windows.h in library was deleted).
I am searching for a code that just include those simple compiler such as stdio iostream, fstream,conio,etc..
so can anyone can gave me an simple code for a graphics with such thing???
or maybe should i ask first if it is possible??
Please help me im "running out of time."