Anyone else using Dev C++ v. 4.9.9.2 ?

I can't figure out how to make it word wrap. Also, when I go to run a project, the window comes up for a split second, then just disappears. Never an error message, just disappears. Any ideas?

Anyone else using Dev C++ v. 4.9.9.2 ?

I can't figure out how to make it word wrap. Also, when I go to run a project, the window comes up for a split second, then just disappears. Never an error message, just disappears. Any ideas?

Maybe I think ur program is corrupt. Try and use sumthing better like visual studio or Turbo C, which is wat I am using.

:cool:

Add a call to cin.get(); just before the call to return 0; in main() to try to hold the program open for viewing. Better yet, use two calls to cin.get(), or do as I do, which doesn't seem to be the mainstream, and call >> on a dummy variable just before return 0;.

Hello, i persume its a console app your working on. By putting

system("pause");

or

cin.get();

so you can see what on-screen. Place either one at any point you want your program to stop and wait for a return key press by you.

Not sure what context you mean word wrap in, maybe if we could see some or your code.

>I can't figure out how to make it word wrap.
What's "it"? This question is incredibly vague, and you're unlikely to get a decent answer from it.

>the window comes up for a split second, then just disappears
Please ignore the majority of what everyone else has told you in this thread. What happens is that the IDE you're using opens a window to run the program, but when the program finishes, it closes the window. To stop it, the conventional method is to request input, which causes a blocking read. Alternatively, you can run the program from the command line. To do a blocking read you first need to clear the input stream of any junk left over from earlier in the program. The correct C++ method is as follows:

#include <iostream>
#include <ios>
#include <limits>
// Any other headers you need

int main()
{
  // Your program here

  std::cin.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );
  std::cin.get();
}

The meat of the solution is cin.ignore, which reads a certain number of characters up to a delimiting character. In this case, you're reading up to the size of the stream characters, or until a newline is found. If you find this to be too complicated because of numeric_limits, you can just use a big number and it'll usually work:

std::cin.ignore ( 1024, '\n' );

The correct C code is basically the same thing, but a little less abstract because you need to implement the functionality of cin.ignore:

#include <stdio.h>
/* Any other headers you need */

void jsw_ignore ( FILE *in )
{
  int c;

  while ( ( c = fgetc ( in ) ) != EOF && c != '\n' )
    ;

  clearerr ( in );
}

int main ( void )
{
  /* Your program here */

  jsw_ignore ( stdin );
  getchar();
}

jsw_ignore reads characters until the end-of-file is reached, or a newline is found. If EOF was reached before a newline, we also need to clear any errors on the stream so that the following request for input will actually block.

>Maybe I think ur program is corrupt.
Maybe I think you don't have enough experience to answer questions.

>Try and use sumthing better like visual studio or Turbo C, which is wat I am using.
You might like them better, but Visual Studio only recently started to improve enough to be considered good, and the Turbo line of Borland compilers suck ass, mostly because they're too old to work with modern code.

system("pause");

system(pause) is the best method.

I suppose, you didn't read the things above.:-O Right, then read all of them and you will remorse for what you said. :) system("pause") is bad and is OS specific. Read more.

This article has been dead for over six months. Start a new discussion instead.