hello. am a new student to programming! am doing c in my computer science class at university, as dev cpp as the compiler; - but am disappointed each time I try to run a program. the program just flashes off the screen! am using windows 7 professional s a platform. what should i do about it? thanx.

Recommended Answers

All 3 Replies

Welcome to Daniweb. But please go to the actual forum(software development) and ask your question.

This is a common problem with IDEs that don't artificially keep the window open for you. The actual problem is that the IDE creates a window to host your program, and when the program ends the window is destroyed. The solution is to force your program to continue running by blocking for input at the end:

#include <iostream>

int main()
    std::cout << "Hello, world!\n";
    // Block for input to keep from terminating

This solution can be a problem if your standard input stream isn't empty at the time you try to block, so for that case you need to clear the stream first as described in this tutorial.

i use c not c++. it turned out to be an error in my source code!

Be a part of the DaniWeb community

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