windows app or console app needed?

Started by
7 comments, last by Xai 18 years, 4 months ago
ok i need some help here everyone is tellin me use a console application until you get better at C++ because im a beginner. im not sure if i NEED a windows app for this though because you cant enter data into a console app. heres the code #include <iostream> using namespace std; int main() { short number1, number2; cout << "Enter a number between 1 and 100: "; cin >> number1; cout << "Enter another number this time between 1 and 1000"; cin >> number2; cout << "\nThe numbers you entered were\n"; cout << "\tNumber 1: " << number1 << "\n"; cout << "\tNumber 2: " << number2 << "\n"; return 0; }
Advertisement
a windows console is msdos, this code is msdos..the windows applet is actually for windows programming, real windows and such..
err say what?
That code is MS-DOS code. It will work in the windows dos prompt if u run it. I suggest that you change your code to:
#include <iostream>#include <cstdlib>using namespace std;int main(){short number1, number2;cout << "Enter a number between 1 and 100: ";cin >> number1;cout << "Enter another number this time between 1 and 1000";cin >> number2;cout << "\nThe numbers you entered were\n";cout << "\tNumber 1: " << number1 << "\n";cout << "\tNumber 2: " << number2 << "\n";system("pause");return 0;}

That will prevent the window from closing before you can view the outputed data.

Edit:
Oh, by the way, I read some of your older posts, Chill, everythings going to be OK.
"Are you threatening me, Master Jedi?" - Chancellor Palpatine
Quote:Original post by maggot789
err say what?


I believe you are.. 'confused'.

A console app is one where you don't see a normal window with colors and everything, but a black one. That is a DOS window. By console we don't mean game console so you don't have a joystick, but we mean DOS. Continue with DOS, if you are a beginner. Once you get good you can move on to windows and advanced things. Good luck!

C++
If you can run your code and you get a window (black screen , ms-dos style window) , then that IS a console window or "console application". It basically means and "ms-dos" window. Pick up "beginning c++ game programming", best book ever.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

you can use "cin>>"something so the msdos window will not closed
ofcause you also can use "system("");"
---------------------------- My English is not very good.
A console window is NOT MS-DOS. This is why console programs are called "Win32 Console" programs - they have full access to all of the Win32 functions, but are provided with a window displaying text so that you can use cin, cout etc.

The OP requires a console program, as he is using cin/cout, and has a Main rather than WinMain function.
If you want to use cin and cout to present applications that read and write text line-by-line (like older DOS programs) - you want a console application ... if you want to use Win32 API functions like DrawText() to put text onto a Window - you need a windows app.

The windows app is MUCH harder to work with at the VERY BEGGINING, because there are many little things that must be done first - such as registering a window class, creating a window, setting up the message loop, registering a window procedure callback function ... so you see there is much more to understand when trying to figure out what your program is doing ... but individually each of those things is simple, so once you are comfortable with basic programing (usually after the equivelent of 1-2 semesters in college, or 3-6 months of self study) feel free to persue the windows programming stuff. When I learned it I used the first 2 chapters of "Windows 98 Programming from the Ground Up" by Herbert Shildt. It was very very helpfull in the beginning of teaching what the main parts of a window are, and the basic message concepts ... I pretty much quite using the book after chapter 3 or 4 ... took a total of about 2 weeks to get comfortable with it all (and I had already programmed C++ for more than a year).

This topic is closed to new replies.

Advertisement