954,498 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Dev C++

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?

kahaj
Junior Poster
193 posts since Sep 2005
Reputation Points: 10
Solved Threads: 0
 

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:

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

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;.

Lerner
Nearly a Posting Maven
2,382 posts since Jul 2005
Reputation Points: 739
Solved Threads: 396
 

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.

freespace
Newbie Poster
5 posts since Dec 2005
Reputation Points: 10
Solved Threads: 1
 

>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.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 
system("pause");


system(pause) is the best method.

ehsen
Newbie Poster
4 posts since May 2005
Reputation Points: 10
Solved Threads: 0
 
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 .

vishesh
Nearly a Posting Virtuoso
1,381 posts since Oct 2006
Reputation Points: 85
Solved Threads: 42
 
system("pause");

system(pause) is the best method.

Your response is just a tad bit late -- by almost two years! :-O

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You