Friday, July 31, 2009

C and C++ Differences between: Win app, Console app, blank.??

Im trying to Learn C then Lear C++ But when I go to run a simple hello world program it never works.





I think im picking the wrong type of project to make in Visual and Dev C++.





What is the Difference between Windows application, Console application, Blank, etc???





When Do I want to use each one??





thanks so much! I cant wait untill I cant figure this stuff out.

C and C++ Differences between: Win app, Console app, blank.??
Your problem may be that you are trying to build a Windows application rather than a console application. For most people learning C and C++, they want to build a console application.





Another problem may be that your are running the program by double clicking an icon of the executable in some folder. In that case, the program is running, but what it is doing is opening a console (DOS interface), executing and closing when it is done so quickly you may not be able to see it.





You have a couple of options here. The first is to open a DOS shell, cd to the folder where the executable is located, and run the program by typing the name into the prompt. We are assuming you made a console program.





Another is to add a sleep() call to delay the end of the execution, leaving the DOS shell up, or using a scanf() statement to have the program wait for input (look up scanf() for proper use). Hit return to close the DOS shell.





If I recall correctly, Visual C++ can execute a program through the IDE after it is compiled. (You did remember to compile your programs, didn't you?) Read your documentation for the details on how to execute a program in the IDE..





Good luck.


No comments:

Post a Comment