Advertisement
Guest User

ydfgdfg

a guest
Dec 11th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.92 KB | None | 0 0
  1. /* HW # 8 */
  2. //Omar Youssef
  3. #include <iostream>
  4. #include <string>
  5. #include <fstream>
  6. #include <cctype>
  7. #include <cstring>
  8. #include <cstdlib>
  9. #include <ostream>
  10. #include <sstream>
  11.  
  12. using namespace std;
  13.  
  14. int main()
  15. {
  16.     string innie, outie;
  17.     string buffer;
  18.     const char* in;
  19.     const char* out;
  20.  
  21.     cout << "Hello Master! Please enter the name of our wonderful input file!" << endl;
  22.     cin >> innie;
  23.     cout << "The name you entered was " << innie << endl;
  24.     in = innie.c_str();
  25.     fstream infile;
  26.     infile.open(in,ios::in);
  27.     //ofstream outfile("con");
  28.     if (infile.fail()) //CHECKING FOR FAILURE OF FILE OPEN SEASAME
  29.     {
  30.         cout <<"Error: the file could not be opened." << endl;
  31.         exit(1);
  32.     }
  33.  
  34.     cout << "Hello Master! Please enter the name of our wonderful output file!" << endl;
  35.     cin >> outie;
  36.     cout << "The name you entered was " << outie << endl;
  37.     out = outie.c_str();
  38.     fstream outfile;
  39.     outfile.open(out, ios::out);
  40. //---------------------------------------------------------------------------------------------------------------------------------------\\
  41.  
  42.     cout << "Hello Master! The contents of out best file ever! Read as follows." << endl;     // Print contents of file
  43.     while (!infile.eof())
  44.     {
  45.         //cout << "in while loop" << endl;
  46.  
  47.         getline(infile, buffer, '.');
  48.         buffer[0] = toupper(buffer[0]);
  49.         for (int i=1; i<buffer.size(); i++)
  50.             buffer[i] = tolower(buffer[i]);
  51.         buffer = buffer + '.';
  52.         cout << buffer << endl;
  53.         outfile << buffer;
  54.  
  55.      }
  56.  
  57.     infile.close();
  58.     outfile.close();
  59.     return 0;
  60. }
  61.  
  62. output.txt
  63. I want you too know that no matter what ill alwayzzzzzzzzzzzzzzzzzzzz diiiiii ddddie dayyyyy dae dieee dei die die die die.
  64.  
  65. input.txt
  66. I wAnt You toO KnoW thAT NO MATTEr what Ill alWayzzzzzzzzzzzzzzZZZzzz dIIIIII DDDDie dAYYYYY dAE diEEE dEI Die dIE die diE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement