Jump to content
  • Advertisement
Sign in to follow this  
maggot789

windows app or console app needed?

This topic is 4860 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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; }

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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++

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!