Sunday, July 26, 2009

How do I execute a C++ program with Visual C++?

I'm writing my program in Microsoft Visual C++ now. After I'm done writing it, I have now idea how to execute my programs. When I save it, it gives me a while folder for my program, and I can't even find an executable file (.exe) in it.


Is there a button I can click in Visual C++ to execute the file like in Bloodshed Dev C++?

How do I execute a C++ program with Visual C++?
There should be a pull down item called Run. But your program will run instantaneously. So a window will momentarily appear and disappear (unless you're writing a GUI-based application)





So the best thing to do is (1) save your program and the compiled, linked executable in some folder


(2) open cmd shell. (In Windows Start-%26gt;run-%26gt;cmd.exe).


(3) cd to your path


(4) run your program by typing %26lt;programname.exe%26gt;. So if your program is called math, then you'd type math.exe.
Reply:Ctrl + F5 will do it.





Or, pull down the Build menu and see the "Execute [projectname]" option....click on it.





Finding the executable:


if you've enabled linking to create an executable, look for sub directories/folders in the project folder named "Release" or "Debug", or both might exist. The executable should reside in one or both of these, depending on the project settings (build for release or debug)





I know...it should be more straightforward than this, but...
Reply:What version of VC do you use?
Reply:When you run it it should dump alot of files in the folder where you told it to. There should be one that looks like a command prompt
Reply:Look on the toolbar, there should be a Play style icon.


Click that icon to make the program then execute it.


Otherwise you need to look in the menus for 'Run program'.


Do a search in Visual C++ help for executing files.


No comments:

Post a Comment