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;.
>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:
// Any other headers you need
// Your program here
std::cin.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );
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:
/* Any other headers you need */
void jsw_ignore ( FILE *in )
while ( ( c = fgetc ( in ) ) != EOF && c != '\n' )
clearerr ( in );
int main ( void )
/* Your program here */
jsw_ignore ( stdin );
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.