Hi people, need some help in closing the window after program execution has completed.
I am running Turbo c++ 4.5 for windows under Win7 32. Thanks.
Heres the sample code:

//Read and display test customer file

#include <stdio.h>
#include <conio.h>
#include <iostream.h>

struct customer
 char c_name[50];
 int i_age;

int main(void)
 struct customer rec;
 FILE *stream;
 if((stream = fopen("Personel.dat", "r" )) == NULL)
    cout << "Error opening file\n";
    return 1;
    fread(&rec, sizeof(rec), 1, stream);
      if(feof(stream)) break;
    cout << rec.c_name << "   age " << rec.i_age << "\n";

 cout << "\n\nEnd of file!";
 return 0;

Well, the line "getch();" is going to wait for the user to type a character before exiting the program. Remove it and the program will exit after printing "End of file!" and the console window will close.

Thanks Mike_2000_17 for your response. I removed the getch() line but the window still wont close. Anything else I can do?

If it does print "End of file", then what you need to do to close the window is to click on the X in the upper right corner. Once it reaches the end of the program, if the window doesn't close by then, then there's nothing to put in your program that will close the window.

I am not using that sample code for anything but pasted it for reference to my question. Yes it prints the files contents and the "End of file" but hangs there until I physically close the window. There has to be something that will close the console window surely?.

Perhaps it has something to do with the fact that you're using a freaking ancient compiler with a state of the art OS. Do you have a similar problem with other free compilers that were written for something newer than Windows 3.1?

You have a point there. I'll go dig up my old XT.

#include <windows.h>
int main()
  return 0;