Source of TestStuff51.cpp


  1: //TestStuff51.cpp

  2: //Tuesday, Mar 25, 2014

  3: 
  4: #include <iostream>

  5: #include <fstream>

  6: #include <string>

  7: #include <iomanip>

  8: #include <cstdlib>

  9: using namespace std;
 10: 
 11: #include "utilities.h"

 12: using Scobey::Pause;
 13: 
 14: int main(int argc, char* argv[])
 15: {
 16:         //ofstream outFile("simple.txt");

 17:         //ofstream outFile("D:\\simple.txt");

 18: 
 19:         //string fileName;

 20:         //cout << "\nEnter the name of the output file: ";

 21:         //getline(cin, fileName);

 22:         //ofstream outFile(fileName);

 23:         //if (outFile.is_open())

 24:         //{

 25:         //        outFile << 6;

 26:         //        outFile << "Hello, world!" << endl;

 27:         //        double d = 3.14;

 28:         //        outFile << d;

 29:         //        outFile << "\nBye!" << endl;

 30:         //        outFile.close();

 31:         //}

 32:         //else

 33:         //{

 34:         //        cout << "\nThe file could not be opened." << endl;

 35:         //}

 36: 
 37:         //ifstream inFile("simple.txt");

 38: 
 39:         //string fileName;

 40:         //cout << "\nEnter the name of the input file: ";

 41:         //getline(cin, fileName);

 42:         //ifstream inFile(fileName);

 43:         //if (inFile.is_open())

 44:         //{

 45:         //        int i;

 46:         //        inFile >> i;

 47:         //        string s1;

 48:         //        getline(inFile, s1);

 49:         //        double d;

 50:         //        inFile >> d; inFile.ignore(80, '\n');

 51:         //        string s2;

 52:         //        getline(inFile, s2);

 53:         //        cout << i << endl;

 54:         //        cout << s1 << endl;

 55:         //        cout << d << endl;

 56:         //        cout << s2 << endl;

 57:         //        cout << "That's all, folks!" << endl;

 58:         //}

 59:         //else

 60:         //{

 61:         //        cout << "\nThe file could not be opened." << endl;

 62:         //}

 63: 
 64:         double sum = 0;
 65:         double d;
 66:         cout << "\nInput some real numbers and terminate with "
 67:                 "the end-of-file character:\n";
 68:         while (cin >> d)
 69:         {
 70:                 sum += d;
 71:         }
 72:         cin.clear();
 73:         cout << "\nThe sum of those values is " << sum << ".\n";
 74: 
 75:         int i;
 76:         cout << "Enter an integer: ";
 77:         cin >> i;
 78:         cout << "The integer was " << i << ".\n";
 79: 
 80:         //double sum = 0;

 81:         //double d;

 82:         //ifstream inFile("reals.txt");

 83:         //while (inFile >> d)

 84:         //{

 85:         //        sum += d;

 86:         //}

 87:         //cout << "\nThe sum of those values is " << sum << ".\n";

 88: 
 89:         //string fileName;

 90:         //cout << "\nEnter the name of the output file: ";

 91:         //getline(cin, fileName);

 92:         //ofstream outFile;

 93:         //outFile.open(fileName);

 94:         //if (outFile.is_open())

 95:         //{

 96:         //        outFile << 6;

 97:         //        outFile << "Hello, world!" << endl;

 98:         //        double d = 3.14;

 99:         //        outFile << d;

100:         //        outFile << "\nBye!" << endl;

101:         //        outFile.close();

102:         //}

103:         //else

104:         //{

105:         //        cout << "\nThe file could not be opened." << endl;

106:         //}

107: 
108:         //outFile.close();

109:         //cout << "\nEnter the name of the next output file: ";

110:         //getline(cin, fileName);

111:         //outFile.open(fileName);

112:         //outFile << "\nThis is the second file.\n";

113: }