Use an IDE that keeps the terminal window open after program termination (such as Code::Blocks) or just run the program from the terminal in the first place.
I think what Athar is saying is that system("pause") is forbidden here.
.....
system("anything") is bad for a lot of reasons. It is platform dependent, error prone, inefficient, and (I have been told) is a security threat (though I'm not sure exactly how).
Instead, use getchar(); or getline( cin, dummyStr ); to wait for something to be put on the input stream before termination. Alternatively, run your program after using 'cmd' in start->run (on windows) or a shell in linux.
that way the program isn't the only thing keeping your cmd prompt open.
lol why is it that even it's said SO MUCH that you shouldn't use system() commands, somehow everyone finds/ hears from someone else that you SHOULD use it?
It's not really forbidden... It's just considered bad practice. It's like using a ton of if statements when switch statement would be a cleaner solution to the problem - either work, but one is a better way to do it than the other.
That link has a good explanation.
system() is platform dependent, meaning that it might work in windows but not on linux. getchar() is not system dependent, and is therefore considered (usually) a better alternative.
For instances when you know/or are designing software only for a specific platform and really know you do not want it to work somewhere else, then I suppose platform portability isn't a concern. Also, if you're just testing something out and aren't putting system (anything) into production/finished code, then it doesn't matter either. It's just a habbit that a lot of people have. I had it, and these forums broke it.
I trust you all when you say that using system() is bad and pointless, but I did that because I just wanted my code to show a simple text with the variable "name", I'm just starting my first classes please do not be mean or sarcastic with me (I didn't mean you have to allow me doing useless things, in facts I like to be fixed as much as possible), I always try the best I can, it was only a practice and I wrote that post when I was in middle of the class because I didn't want to seem "The fool of the class who can't keep a simple software open" (Even though I was not the only one with troubles, I like looking for solutions by myself)
I am not a nOOb, I'm just a newbie. However I won't do anything else regardless what you told me.
See you and thanks to everyone for his\her time. I'll keep myself improving the way that I program.
I'm glad your trying to learn - my last post wasn't intended to throw darts, so to speak, just to point out something that people take heat for. Like I said, for just a little practice/homework assignment, it probably doesn't matter.
why is it that even it's said SO MUCH that you shouldn't use system() commands, somehow everyone finds/ hears from someone else that you SHOULD use it?
Well I don't know about in general, but I have used System() in the past primarily because it gets the job done, and I don't have to know the source code to implement it into my program natively. And primarily because since I am probably going to be the main person using the programs that I wrote that included System() calls, I can personally verify that the executed commands are indeed infact what they are supposed to be, which mutes the point of System calls being insecure.
I do as a rule of thumb, especially more recently as I have gotten somewhat better at programming, do try to avoid it whenever possible.
I wasn't trying to be mean (guessing you referred to me), but it's just something i've been noticing.
@wtf:
quite true, but still, it gives slower preformances (especially in bigger programs where you could, e.g, use something like system(cls), system(pause) system(color//something) etc...)
And getchar() is shorter then system(pause) (but thats just for lazy ppl like me)