why do my programs just flash off the screen when i try to execute them?
i am new to programming, don't forget!

Recommended Answers

All 4 Replies

its because output screen is not holding, it's displaying output and goes off..you can use scanf("%c",&hold); before return 0 to hold the screen.
and carefull don't forget to declare hold variable as char.
check this:-

int main(){
    char as;
   /*your code.........
.....................
..........................
...........................
............................
*/
    scanf("%c",&as);
    return 0;
}

The question is actually why wouldn't your programmes disappear when they're finished? What are you doing to keep them visible? Nothing.

Your programme is a console programme; when you run it, a console is brought into existence. When the programme finishes, the console closes. If you open a console yourself first and then run the programme from that command line, the console will remain when the programme finishes.

Additionally, you're not doing yourself any favours using Dev-C++, especially now that C++ 11 is out.

thank you! it worked perfectly!

I am using dev cpp too. I am using version Dev cpp 4.9.9.2. 2nd posibility (after launch straight from console)you can do is (mean in my version) that you have to, when you want to create some console application, follow this: File/New/Project, there select console application and create it. Then you have to save it (sooner or later during compilation). Source code look like this or similar:

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    system("PAUSE");
    return EXIT_SUCCESS;
}

where system("PAUSE") function make what you want.

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.