C++ project running in something other than cmd
#include <iostream>
using namespace std;
int main()
{
int carrots;
carrots = 25;
cout << "I have " << carrots << " carrots." << endl;
carrots = carrots - 1;
cout << "Crunch crunch, i now have " << carrots << " carrots." << endl;
return 0;
}
When ii compile and run this code with microsoft visual c++ it opens in command prompt all the time with anything. Ive seen applications in C++ in a fully user friendly format like a VB app.. WTH is it always opening in cmd?
help is mre than appreciated
thanks
Re: C++ project running in something other than cmd
That's what that program was designed to do.
build an interface for it!
What exactly is your question?
Re: C++ project running in something other than cmd
Quote:
Originally Posted by bobdabilder
That's what that program was designed to do.
build an interface for it!
What exactly is your question?
He wants to know how to give it a window and such, instead of the black monolith we know as the command window.
I won't show you how to create a window, there's tons and tons of tutorials out there for that. Just google "CreateWindow C++ Example" or something.
BUT: For getting rid of the command window, all you have to do is use WinMain instead of main. It looks like this:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);
Where:
hInstance: A handle to the program this function's in.
hPrevInstance: A handle to the last copy of this program that was opened.
lpCmdLine: The command line that was called with the program. For example, if the program was called like typing "C:\Program.Exe /1", "/1" would be the command line.
nCmdShow: This is a 'suggestion' of sorts from windows as to how the programs primary window should be opened, as in maximized, minimized, whatever.
Re: C++ project running in something other than cmd
building a windows form application is easy in vs2005 etc. or you can go the api route.
Re: C++ project running in something other than cmd
Quote:
Originally Posted by bobdabilder
building a windows form application is easy in vs2005 etc. or you can go the api route.
I hate having the program do anything behind my back, tis why I switched to C++. API all the way, babeh.