![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Mar 2005
Location: Lubbock, TX
Posts: 30
Rep Power: 0
![]() |
My C programs instantly close
I am just starting out on programming. I am using Microsoft Visual C++, and when i run the program in there, it will ask to press a key to close, but when i find the program on the computer, it closes the instant the program is done instead of waiting for you to close it yourself. Is there a better C compiler and development program out there that's free?
Thanks, David |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Mar 2005
Location: Lubbock, TX
Posts: 30
Rep Power: 0
![]() |
P.S. - I put
getchar(); |
|
|
|
|
|
#3 |
|
Expert Programmer
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 550
Rep Power: 4
![]() |
Programs close when they get to the end of the code
You could use getchar() at the end, or include stdlib.h and use system("pause");
__________________
Johnny was a chemist's son but Johnny is no more, for what Johnny thought was H2O was H2SO4 |
|
|
|
|
|
#4 |
|
Newbie
Join Date: Mar 2005
Posts: 4
Rep Power: 0
![]() |
cin.ignore();
cin.get(); |
|
|
|
|
|
#5 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
Post the code here.
Also, the getche() function in conio.h might solve your problems instead of getchar().
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower |
|
|
|
|
|
#6 | |
|
Hobbyist Programmer
|
Quote:
It's truthfully frusterating when people make system(); calls in a program that isn't Windows centric, like programs that involve Win32 and/or WinSock programming. Or something of the like, such as Registery editing. You should use Getchar(); or getch(); at the end of your code. But getch(); isn't part of the ANSI C standard so it might not work. The only reason I can think this is happening, is that you fucked up somewhere in your code in which case stuff is truncated. It's happened to me, with scanf(); and truncating spaces. Last edited by Mad_guy; Mar 20th, 2005 at 5:13 AM. |
|
|
|
|
|
|
#7 |
|
Programmer
Join Date: Mar 2005
Location: Lubbock, TX
Posts: 30
Rep Power: 0
![]() |
is there a different development program i can use instead of microsoft visual c++?
|
|
|
|
|
|
#8 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
There's Dev-C++.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower |
|
|
|
|
|
#9 |
|
Programmer
Join Date: Mar 2005
Location: Lubbock, TX
Posts: 30
Rep Power: 0
![]() |
where do i get it?
|
|
|
|
|
|
#10 |
|
Expert Programmer
|
there is also gcc, many windows ports of it also.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|