I started a windows application, that used the void hide.. function to hide the command window. I compiled it, and it worked. Why is it, that if I compile the source file, and not the project file, it keeps the window open? Dispite the fact the coding is exactly the same?

Thanks

depends on the compiler you are using. Some IDEs will keep the console window open and others won't.

I checked my project file extension, it's .dev. And my source files have a variety of different extensions. So it's possible that .dev when compiled(As a windows app.) doesn't support the console feature? I presume so...

Thanks

.dev is just a project file that Dev-C++ IDE uses to maintain the *.cpp and *.h files you have in your project. It has nothing to do with the console window. When in Dev-C++ IDE you have to put something just before the return in main() to keep the window open. If you don't then Dev-C++ will close it when the program finishes. On the otherhand, when you create a command window from the Start button that window stays open until you close it and you can run most porograms from it without closing that window.

int main()
{
   ,,,
   // keep the window from closing
   cin.get();

   return 0;
}

Note that what I posted above is only one of several ways to keep the window from closing.

Yeah, that makes sense. It's because I ran a program with a loop inside of it, although I managed to prevent the window from opening in the process using a windows application, but strangly, an empty compiled project kept it open when doing this, along with a blank command box.

Any ideas?


EDIT Also, I can only use the void hide function inside of a windows app, but I already know this...

Not sure I completely understand what you are after. You want the program to run and have a console window open? The console window is open, but closes too soon? You don't want any console window to pop up ever, even when the program is running?

If the last is what you want and you are using Dev C++, there is an option under:

Tools --> Compiler Options--> Settings --> Linker

called "Do Not Create a Console Window". It's default is "no". In other words, the default is to create a console window. Change it to yes and no console window is created. This is irrespective of any code that you have. Thus you don't have to produce code that "hides" the console window. The compiler option did it for you. However, take that code and take it to another compiler or to a project where that option is not "yes", and the command window will open. Same source code, different result.

Part of the .dev file, I think, is to store that compiler option.

I'm not sure if that addresses your question or not.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.