ok, here is the deal, I have to do a couple of programs for my C++ class and I will be using devc++, now I have this educational version of borland which works similar to what they have at school, but I still have the problem of the program ending early. At school I don't have the problem, I made a program, and it ran fine, didnt' close early or anything, but when i had the exact same program ran on my comp, it ends early. I have no Idea why it did this, is there some setting I have to put. Also, at school, it executes a program with a white screen instead of a black one. I just don't want to hand in a program that won't compile and get an F on my first assignment.
You have to pause the system. They are many ways to do it. For example, you can use cin.get() or system("PAUSE"). The system pause only works on windows/dos systems. BTW, other people might tell you to use kbhit or other functions in conio.h. Try to stay away from these though b/c they are non-standard functions and everyone might not have them.
P.S. The system function is located in <cstdlib> or <stdlib.h>
P.S.S Try searching the board before you ask questions next time because this question has been asked many times before. It is also in the FAQ at this site.
golfinguy4 is on the money here.
The white screen/black screen issue is an implementation default which, in regular people terms, means that it depends on which compiler you're using.
Now, I wish you were using Borland at school and devc++ at home. Borland is, in my experience, more accepting of code compiled on other compilers, i.e. MSVC++ code compiles quite readily on Borland, but not necessarily the other way around. However...
If your instructor knows what he/she is doing, he/she will have a laptop with both compilers installed allowing the student to write his/her code into either. (Tell your instructor that golfinguy4 said so. :D )
I know, I'm making light of this and you're feeling panicked. Never panic. You'll do fine!
I have a better idea, why not open up a dos window and run your executable from where it is supposed to run?
hmm, I put in the system pause function and tried to compile it with the version I have and it didn't fully compile it. I think the version I have is a bit old, it's version 5.02. I am afraid that if I hand it into the teachere and it doesn't compile I will get my first low grade. I used the "system("pause"); function along with the header file iostream.h. Now I know that in the verison we have at school, it will get an error with .h after the header, but I don't know if the pause function will work. To be safe, should I just put something such as
to keep the prog from closing. Sorry if this has been asked but I didn't have much luck when I searched.
Include <cstdlib> ( or <stdlib.h> if using the old header files)when using system().