Important Note(A post to end all newbie topics concerning......)
Everyday for the last two months I've found threads started by newbies concerning this topic:
How do I keep a window from closing?
My window closes automatically, help!!!
How do I prevent a window from closing fast?
Well, I've made this topic to help answer that. So that when newbies could look at this topic before they post.
For the Dev-C++4 IDE(Compiler: MingW), and some others. The functions to keep a window from closing are as follow:
1. system("pause");
2. Sleep(number_of_Miliseconds);
3. getch();
4. getchar();
5. cin.get();
----------------------------------------------------
1. Include stdlib.h, this is really a C function
2. Include windows.h, the function name is case sensative. The S must be capitalized. Place the number of miliseconds in the paranthesees. This is bad practice using this function as a window close preventer, but it is possible.
3. Include conio.h(conio.c in Dev-C++), place this before return 0;
4. Same as getch();
5. Most advance programmers use this. Most programmers would say that cin.get is the best way.
[GB Edit: ] Mods, it wouldn't hurt to stick this topic. It is helpful. Also if there are any programming mistakes within this topic. Feel free to edit it. The newbies will read it so it has to be perfect.
Re: Important Note(A post to end all newbie topics concerning......)
Quote:
Originally posted by Golden Bunny
3. Include conio.h(conio.c in Dev-C++), place this before return 0;
Dev-C++ has conio.h. No need to do that. It uses the mingw port of GCC and as such is pretty complete on what comes to standardized libraries. Besides, one should never do include statements for code files.
I don't know much about C/C++. So, as a newbie, I'm perfectly comfortable to say that the above won't help anyone. On the contrary...
Re: Important Note(A post to end all newbie topics concerning......)
Quote:
Originally posted by Golden Bunny
2. Include windows.h, the function name is case sensative.
Only now noticed this one...
Without further explanation (and considering newbies like me would read this) it implies this particular function is case sensitive, when in fact C/C++ is case sensitive all over.