🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Why is it doing this?

Started by
7 comments, last by mx1 22 years, 7 months ago
I am trying to make the hello world program in Borland C++, but after I do, and then click on the .exe file it just shows the command prompt for a split second then it crashes back to the desktop. I am writing it just like the tutorial here says.http://newdata.box.sk/bx/c/htm/ch01.htm This tutorial does not tell me how to build it or compile it or link it or anything though, maybe that is what I am doing wrong. Is there any way to post a screenshot?
Advertisement
There doesn''t sound like there is anything wrong with the program.

Chances are that Windows is just closing the command window when your program exits.
It seems like your program DOES execute, but in Windows, there''s a switch which causes it to close console programs immediately upon completion. What you could do is run your program directly from the console, or then try to find and disable the aforementioned option.

You know how to use the console, right?


rk
I am kindof a newbie.
Can you please tell me exactly how to use the console?
I am using Windows 2000.
mayby this is wrong but if you have written the code like this

  void main(){   cout << "Hello world!"; //or perhaps printf("......}  


the program will exit emidiatelly after the program has written hello world. to fix this you have to add a "command" called getch(), like this...

  void main(){   cout << "Hello world!"; //or perhaps printf("......   getch();}  

Hmm, kind of a massive question, but you just need to open a console window (by running "cmd.exe"), then changing into the directory of your program... for example, if your program is in D:\Work\C\Hello\Hello.exe :

d:
cd "work\c\hello"
hello.exe
To add getch() I believe you need to include conio.h.

Edits: gak, multiple source blocks in quotes just does not work.

Edited by - draqza on December 4, 2001 10:26:48 AM
WNDCLASSEX Reality;......Reality.lpfnWndProc=ComputerGames;......RegisterClassEx(&Reality);Unable to register Reality...what's wrong?---------Dan Uptonhttp://0to1.orghttp://www20.brinkster.com/draqza
Ok I was able to do it from the console.
I think you guys are right, Clicking on the exe file and running it from there immediately closes the console after it shows, "hello world". Is there any way that I can stop this?
I would really like to be able to run these programs from the .exe file.
Thanks for all the help. I really appreciate it.
You could also right click on the exe file and under program remove the flymark in "Close on Exit". That will keep you programs open after exit.

I think there is a general switch you can set somewhere, look at msdn for any information.

Hope this helps

-- Sturm

---------------------------------------------------
Life after death? No thanks, I want to live NOW
--- Sturm 2001
---------------------------------------------------Life after death? No thanks, I want to live NOW --- Sturm 2001

This topic is closed to new replies.

Advertisement