/* Filename: makefile.cpp Author: Br. David Carlson; Br. Isidore Minerd Date: October 25, 2004; July 16, 2009 This program reads floating point numbers from the keyboard and writes them to the readfile.txt text file. The numbers should be entered one at a time, as prompted. Use CTRL z to end data input when using Visual C++ on a PC. You may need to press ENTER a couple of times. However, this must be changed to using CTRL d when using g++ under Linux, as CTRL d is the Unix/Linux end of file. It will also terminate when non-float data is input. Tested with: Microsoft Visual C++ 6.0 Microsoft Visual C++ .NET Microsoft Visual Studio 2008 g++ under Linux */ #include #include using namespace std; int main(void) { float Num; fstream OutFile; OutFile.open("readfile.txt", ios::out); if (OutFile.fail()) { cout << "Open of readfile.txt failed" << endl; exit(1); } // Warning: Change this to CTRL d for Linux: cout << "Enter a floating point number (or CTRL z to end): " << endl; cin >> Num; while (! cin.fail()) { // Process the data: OutFile << Num << endl; // Warning: Change this to CTRL d for Linux: cout << "Enter a floating point number (or CTRL z to end): " << endl; cin >> Num; } OutFile.close(); return 0; }