Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   disapearing program (http://www.go4expert.com/forums/disapearing-program-t6000/)

johanjohan 24Aug2007 00:55

disapearing program
I know this is pretty basic stuff, but Im having a problem with this program. It keeps dispearing off the screen with out finishing

It disapears after i enter the name of out_file_name

I have system("pause") at the end because im using a dev compiler and if that pause isnt put ther the program will run real fast and disapear off the screen. the system ("pause") prevents that.

thank you

#include < fstream>
#include <cstdlib>
int main()
using namespace std;
  char in_file_name[16], out_file_name [16];
  ifstream in_stream;
  ofstream out_stream;

cout << "I will sum six numbers taken from input\n"
    << "file and write the sum to an output file.\n";
cout << "Enter the input file name (maximum of 15 characters): \n";
cin >> in_file_name;
cout<< "Enter the output file name (maximum of 15 characters): ";
cin >> out_file_name;

// its right here that the program disapears off the screen

cout << "I will read numbers from the file"
    <<  in_file_name << "and\n"
    << "place the sum in the file\n"
    <<  out_file_name <<endl;
if (in_stream.fail())
    cout << "Input file opening failed.\n";
if (out_stream.fail())
      cout << "Output file opening failed.\n";
int first, second, third, fourth, fifth, sixth;
in_stream >> first >> second >> third >> fourth >> fifth >> sixth;
out_stream << "The sum of the first 3\n"
          <<"numbers in" << in_file_name << endl
          << "is" <<(first+second+third+fourth+fifth+sixth)
          << endl;

cout <<"end of program.\n";
return 0;

johanjohan 24Aug2007 01:09

Re: disapearing program
I want to change this program from doing numbers to doing letters and character (%, *, \ )
to do word counts in any file. to see how many times a certain word or character is in a file. Im not looking for it to find it where its at in the file, I just want to have it count.


DaWei 24Aug2007 01:58

Re: disapearing program
I don't really think you would move into a community, attend the church, and fart loudly during the sermon. You would probably wait until you had determined that was the norm for that community. Surely you could accord us the same courtesy.

Check out the community.

johanjohan 24Aug2007 02:54

Re: disapearing program
wow, you got to be kidding

DaWei 24Aug2007 03:01

Re: disapearing program
Nope, I'm not kidding at all. I'm encountered lots of dummies in 66 years, and I'm sure you will too. You move in here, ask for free help, but don't even bother to read the "Before you make a query" thread. It makes me think you're probably still hanging onto your mama's tit for free meals. If you're one of those more and more commonly encountered people who think they are born entitled, perhaps you should read some Eric Raymond.

johanjohan 24Aug2007 03:18

Re: disapearing program
whats with all the degrading?

johanjohan 24Aug2007 03:37

Re: disapearing program
can someone please help me with this program

thank you

shabbir 24Aug2007 08:26

Re: disapearing program
You need to have some user input before the program exits through main or exit function and that should solve the problem.

seeguna 24Aug2007 10:21

Re: disapearing program
Ur program works well in MS Vc++ 6 compiler..........

DaWei 24Aug2007 12:15

Re: disapearing program
Unfortunately, programs are rarely launched by using a compiler, much less VC++ 6.0, which is now ten years old. Programs typically run until they are done, then exit. If one wants them to wait for user input to exit, then one asks for user input, whether that be a "Press Enter" or a button or the big X in the upper-right corner, or whatever.

All times are GMT +5.5. The time now is 17:24.