| int main (93) | |||
|
@Duoas Intersesting post. But it does not quite answer my question. I am using MS C++ Visual Studio 2008. When I follow your link to Microsoft, they tell me to use
to clear the screen. But my question was, what should I use since system("cls") seems to be bad practice? And one thing I do not quite grasp is that you are always talking of taking away the control from the user, but I only use "cls" after the user has done something to trigger it. Say, I ask "Do you want to do soemthign again (y(n)?" and then, if it is a yes, I usually use system("cls") to reset the screen. So, the software is controlled by the user. So far I have not programmed anything (in c+) that was not supposed to be controlled by a human. regards int main | |||
|
Last edited on
|
|||
| Duoas (6752) | |
|
This is going to sound harsh, but I don't mean it badly. You have not made sufficient effort to understand the underlying concepts I have tried to teach you. In technical and industrial programming places it is not uncommon for an employee to be given a 500 page technical manual and be expected to return to work the next day familiar with its contents. The same holds true for other disciplines. If you want to be a doctor, you spend a lot of time reading huge manuals on every kind of disease and function of the body -- and you are expected to remember it. If you want to be a lawer you spend four years studying and preparing for the bar exam. A lot of people don't pass it. The link I gave you has, in a big grey box, a complete, 40-line function that you can cut and paste directly into your program to clear the screen. Everything the computer does is ultimately controlled by a human. The issue isn't whether humans exist -- it is what options the human has in manipulating the program. I am aware that you have only written very simple programs so far, where you expect someone to be sitting there typing 'y' or 'n' to questions and the like. It is time to move beyond that constricted point of view and learn how to make your programs more intelligent, safer, and more usable in a powerful, industry standard way. If this were just a normal thread I might have just given you a link to the MS site and nothing else. But since this is stickied you get the lecture as a bonus. I don't give it because I think you are stupid. I give it because I think you are smart, and capable of learning how to make better software. Now go, young grasshopper, and exhibit some kung fu. | |
|
Last edited on
|
|
| Grey Wolf (3232) | ||||
int main wrote:
| ||||
|
Last edited on
|
||||
| metalmop (21) | |
|
who would have thought that a beginner's forum would turn into a massive debate. instead of using windows to program like the losers you all apparently are, use linux, and even if your ide doesn't say to keep the terminal open, it keeps it open anyways. | |
|
|
|
| Zaita (2400) | ||
Who would've thought a newbie 15 year old would turn it into a "linux is awesome, windows sucks because I said so" thread. | ||
|
|
||
| Grey Wolf (3232) | |
| [Deleted] off topic posting | |
|
Last edited on
|
|
| metalmop (21) | |
|
whoa... what i meant to say was that for programming, and everything in general really, but especially programming, linux is the proven choice it's not like i don't know what i'm saying, i programmed for windows for a long time, even video games. i programmed a lot of windows programs. i know what i'm saying when i say that linux has a better programming environment than windows because i have used both. and if you guys were on linux, you wouldn't be arguing about this because there is no need for pausing the terminal just because i'm fifteen, doesn't mean that i don't know jack squat about c++ programming. now i admit, calling you guys losers for programming on windows went a little bit to far and i'm sorry. and a couple of you guys have helped me out and i'm greatful for that. what i was trying to point out in the initial comment was that point a: a beginner was asking a simple question about keeping the console window open, and that turned into a massive debate, which by no means was meant to be so, seeing as how the initial poster has not gotten involved in the discussion. point b: linux has a better programming environment and is better in general, and you would gain a great benifit by using it, seeing as it would make your life easier in programming, particularly in C++. | |
|
|
|
| Duoas (6752) | |
|
Metalmop, please stop hijacking this thread. It was stickied because this issue is a common one, whether reasonable or not, and it does not help beginners to have to wade through someone else's issues. The OP got his answer and more. If you want to propound the virtues of Linux please start a new thread in the Lounge, and I'm sure you'll get a lively discussion going. | |
|
|
|
| Jacob (10) | |
| Dont use "system pause" because it sucks, you can google it... you best use "cin.get();" wich plain waits for a key to be pressed thank you. | |
|
|
|
| Zaita (2400) | ||
| ||
|
|
||
| Tbc (1) | |
|
Hello all, and I'm a completely new to all this C++ and am having a go at it, In the first page what does Ropez mean by IDE? and does the bloodshed Dev-C++ have the option to keep the cmd open that you mentioned? Sorry if these are answered elsewhere but I'm a bit stumped, and to metalmop, this is a BEGINNER thread, and windows is a normal friendly environment for most computer users, if you get into heavy programming, by all means, use linux, but I don't think most of the people looking through here for help are ready for the hard yards yet. | |
|
|
|
| Duoas (6752) | |||
|
IDE http://en.wikipedia.org/wiki/Integrated_development_environment Dev-C++ does not. Please don't beat up on anyone for past stuff. Personally, I use the command window all the time, so I've got it set up to position itself real purty-like and automatically load all my custom commands and directories. I've even got little batch scripts to load an environment based upon the programming tool in use. For example, in my D:\bin directory, I've got g++.bat
(The mpath program is one I wrote to manipulate the %PATH% variable.) So if MinGW's g++.exe is not in the path, it (a)dds it to the head of path and starts it normally. Thereafter the batch file is skipped entirely, since it finds the g++.exe first. ;-) | |||
|
|
|||
| maximusb (2) | |
| there is nothing wrong with using system("pause") if you remembered to include <stdlib.h> | |
|
|
|
| QWERTYman (458) | |
|
I've used the system() functions in early programs, and I didn't need the cstdlib header file. That isn't to say that other people won't need the header. My 2 cents... | |
|
|
|
| personjerry (8) | |
|
wow you should really read the other posts system() is a function that calls on the Operating System which we would expect, because of its name. There are many more than just one operating system, of which would interpret the string passed to the function differently. This makes your code less portable, which was why C/C++ was made and people use assembly less. Example: system("pause");will tell the system to do the "pause" command. In Windows, this creates the "Press Any Key To Continue...". However, in Linux, or Unix, or Macintosh, or most other operating systems, this will create a runtime error at best, and compile error at worst. In Linux I could do system("ls");which wouldn't do anything in Windows, but in Linux is a very common command (equivalent to DOS's dir command). So unless you want to be stuck with Windows in this era of what seems like the death of Microsoft, it is much better to learn, and get in the habit of using other techniques--portable techniques. | |
|
Last edited on
|
|
| helios (10258) | |
|
Although I shouldn't speak for him, I believe he likes it for the same reason I do: while it does use system(), it does so in a clever way; by taking advantage of the fact that static objects are automatically deleted. Kudos to you, ropez! Another version I've seen (implemented in Code::Blocks) uses a program to call the program being tested (through the use of system(), I presume) and after the latter returns control to the former, which then proceeds to use some method to capture input (might be system("pause"). I can't remember right now). This has the advantage of not having to add anything to the program. | |
|
|
|
| Duoas (6752) | |||
...which is the correct way for it to be done. I am always surprised that IDE's so often lack this feature. The code to do it is trivial:
Alas. | |||
|
|
|||
| helios (10258) | |
|
OSHI- I'm so embarrassed! I thought I was looking at the last page when I was actually looking at the first. | |
|
|
|
| kacko (55) | |
|
I hope i ask this correctly as to not look like a total idiot. I have, at this point, read all the post in this thread and still have a burning question, and I will ask it in an example. EXAMPLE: I am writing a console Tic-Tac-Toe game. When the X player enters his move (2,3) I need to draw the tic tac toe board to reflect the change. I don't want to keep the old one there, and just redraw the new one below the old, so in my mind, I would want to clear the screen. Would this be an acceptable place to add a system("CLS") , or any other method of clearing the screen? I understand the point of not using the system() function due to operating system, and accept it. so could I use Grey_Wolfs post? If not, how would I reach the desired effect? | |
|
|
|
| kacko (55) | |
|
I hope i ask this correctly as to not look like a total idiot. I have, at this point, read all the post in this thread and still have a burning question, and I will ask it in an example. EXAMPLE: I am writing a console Tic-Tac-Toe game. When the X player enters his move (2,3) I need to draw the tic tac toe board to reflect the change. I don't want to keep the old one there, and just redraw the new one below the old, so in my mind, I would want to clear the screen. Would this be an acceptable place to add a system("CLS") , or any other method of clearing the screen? I understand the point of not using the system() function due to operating system, and accept it. so could I use Grey_Wolfs post? If not, how would I reach the desired effect? | |
|
|
|