Sign in to follow this  
Lanky007

quick black screen

Recommended Posts

I am using VC++ 6.0 Professional edition, I can compile and run my program just fine, except when after I compile it in release mode and go to the folder the workspace is in, and double-click the executable it comes up and then just disappears. I think this might have to do with VC's non-distributable thing or something but I don't know. If I run the code from within the workspace environment, it works fine, but the double-clicking the executable will do the quick screen thing. Anyone know why this happens?

Share this post


Link to post
Share on other sites
Well it might be because the program runs really quick and then exits. I am not sure with C++ 6.0 but with mine system("PAUSE"); does the trick and I have heard of getch(); or getchar(); doing the trick.

Share this post


Link to post
Share on other sites
The preffered way of stopping your program before it quits is to put a breakpoint on the very last line of your program.

Never ever use system("PAUSE"); (each time you do so, God kills a kitten. Really). You may use std::cin.get() or any other function that waits for a keypress, but this is a dull solution since you don't expect a console program to wait for a key before it quits: it prevent you from putting this program in a non-interractive batch or command file.

Regards,

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
What's the matter with system("pause")?
I use ist and have no problem. And nowadays is DOS out, why bother about it.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
What's the matter with system("pause")?
I use ist and have no problem. And nowadays is DOS out, why bother about it.


Well...
1) Did you ever try to use system("PAUSE"); on a Unix system?
2) Do you really understand that you are launching the Windows command intrepreter in order to call its PAUSE instrisic in order to wait for a keypress? What do you expect to get if your user is using another command interpreter like tcsh?
3) Do you remember that you can wait for a keypress using a single line expression in C++? (std::cin.get())
4) If I put a PAUSE.exe in your program directory, I can do whatever I want. Teh cool.

I can still use command line programs to do complex tasks. Saying that command line programs are dead is plain... weird. At least, linux freaks are still considering command line tools as very valuable, and I believe they are right.

Regards,

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
1. Who cares about UNIX/Linux!!! Thats no OS, thats a toy! Have you tried to work with it? It's not possible!

2. Who cares about such things? DOS is old and out of business. Nobody uses it today for serios things.

3. I know enough methods to pause a programm.

4. see 2.

PS: see 1. and a word to linux freaks: Search for another hobby jerks! Linux will never be an OS.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
1. Who cares about UNIX/Linux!!! Thats no OS, thats a toy! Have you tried to work with it? It's not possible!

2. Who cares about such things? DOS is old and out of business. Nobody uses it today for serios things.

3. I know enough methods to pause a programm.

4. see 2.

PS: see 1. and a word to linux freaks: Search for another hobby jerks! Linux will never be an OS.


I was going to respond to this, but then I thought "Really, why bother." Idiot.

[Edit] I'm not too bothered about my rating, but I really cannot believe someone just rated me down for that. Dear, oh dear.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
1. Who cares about UNIX/Linux!!! Thats no OS, thats a toy! Have you tried to work with it? It's not possible!

2. Who cares about such things? DOS is old and out of business. Nobody uses it today for serios things.

3. I know enough methods to pause a programm.

4. see 2.

PS: see 1. and a word to linux freaks: Search for another hobby jerks! Linux will never be an OS.


while (true) you.stupidness++;

Share this post


Link to post
Share on other sites
Quote:
Original post by Lanky007
I am using VC++ 6.0 Professional edition, I can compile and run my program just fine, except when after I compile it in release mode and go to the folder the workspace is in, and double-click the executable it comes up and then just disappears. I think this might have to do with VC's non-distributable thing or something but I don't know. If I run the code from within the workspace environment, it works fine, but the double-clicking the executable will do the quick screen thing. Anyone know why this happens?


Getting back on topic. The problem is windows closes the command shell automatically when a dos program terminates. One solution to this problem is to open a command shell first (run cmd.exe) and then your executable. You can also make a registry tweak, to add the ability to run the command shell at any folder. This will let you open a shell right in your release folder.

I think there use to be an option in DOS shortcuts that would allow you to force the window to stay open after execution, but I no longer see it in XP.

Hope that helps.

Share this post


Link to post
Share on other sites
That cin.get() works if it is a Console Application, but mine was a Win32 Application so it didn't work with that. I also tried opening up a cmd shell and then running it, still nothing. But I realize my slowness even more now, I figured out what the problem was. I am making a simple little Pong game using SDL and so the program requires access to a bunch of images (background, paddles, ball, etc). So when VC++ makes a release version, it makes a folder in the working directory called "Release", and that is where the executable is, but the program as it was written expects all the image files to be in the same directory as the program so I just moved the executable from the "Release" up (back to the working directory) one directory to where all the images and fonts and such that it expects were and it worked. Ok, so now I have a new question, is there any way to make an executable where these images don't need to be accessed? Like if I wanted to run this program on a different machine I would have to supply all the images as well, but is there any way around that so just the executable is needed to run the program?

As for the linux business. I know next to nothing about it. For the purposes I use the computer, Windows works fine, and I have had no reason to look for different OS's or semi-OS's, etc. I used linux a few times, and for my purposes for using computers, I prefer Windows. I like buttons, mouse-clicking and...windows and all that stuff. I found something...

http://www.microsoft.com/windowsserversystem/facts/default.mspx

Share this post


Link to post
Share on other sites
Quote:
Original post by Lanky007
That cin.get() works if it is a Console Application, but mine was a Win32 Application so it didn't work with that. I also tried opening up a cmd shell and then running it, still nothing. But I realize my slowness even more now, I figured out what the problem was. I am making a simple little Pong game using SDL and so the program requires access to a bunch of images (background, paddles, ball, etc). So when VC++ makes a release version, it makes a folder in the working directory called "Release", and that is where the executable is, but the program as it was written expects all the image files to be in the same directory as the program so I just moved the executable from the "Release" up (back to the working directory) one directory to where all the images and fonts and such that it expects were and it worked. Ok, so now I have a new question, is there any way to make an executable where these images don't need to be accessed? Like if I wanted to run this program on a different machine I would have to supply all the images as well, but is there any way around that so just the executable is needed to run the program?

As for the linux business. I know next to nothing about it. For the purposes I use the computer, Windows works fine, and I have had no reason to look for different OS's or semi-OS's, etc. I used linux a few times, and for my purposes for using computers, I prefer Windows. I like buttons, mouse-clicking and...windows and all that stuff. I found something...

http://www.microsoft.com/windowsserversystem/facts/default.mspx



If your doing a Win32 app research how to include resource files. This way your additional content is included either directly in the executable or provides a way to provide path names for your files so you can segregate say music and video files into two separate folders. Using the second method you would need an installer program to ensure your files are placed into the appropriate folders.

Share this post


Link to post
Share on other sites
Quote:
Original post by Lanky007
why (!!cin) instead of (cin) or for that matter, instead of (!!!!cin) or (!!!!!!cin) or.... well u get the idea. lol just curious...


That's true, I really don't see the point either. I tried it and every time two !! are used, they kind of take out eachother and evaulate true anyways. Well it's not originally my idea, I got that from a c++ site and I has used it in every c++ program since then. Logically it should be like this in my option:
while (!cin) cin.get(); because that should mean that it activates the cin.get function while there are no other cin functions active, looks like there is a big illogical hole.

Just use while (true) or while (1) instead they are much kinder :))
or just use cin.get plain and simple like it is, that should do it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this