Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* HW # 8 */
- //Omar Youssef
- #include <iostream>
- #include <string>
- #include <fstream>
- #include <cctype>
- #include <cstring>
- #include <cstdlib>
- #include <ostream>
- #include <sstream>
- using namespace std;
- int main()
- {
- string innie, outie;
- string buffer;
- const char* in;
- const char* out;
- cout << "Hello Master! Please enter the name of our wonderful input file!" << endl;
- cin >> innie;
- cout << "The name you entered was " << innie << endl;
- in = innie.c_str();
- fstream infile;
- infile.open(in,ios::in);
- //ofstream outfile("con");
- if (infile.fail()) //CHECKING FOR FAILURE OF FILE OPEN SEASAME
- {
- cout <<"Error: the file could not be opened." << endl;
- exit(1);
- }
- cout << "Hello Master! Please enter the name of our wonderful output file!" << endl;
- cin >> outie;
- cout << "The name you entered was " << outie << endl;
- out = outie.c_str();
- fstream outfile;
- outfile.open(out, ios::out);
- //---------------------------------------------------------------------------------------------------------------------------------------\\
- cout << "Hello Master! The contents of out best file ever! Read as follows." << endl; // Print contents of file
- while (!infile.eof())
- {
- //cout << "in while loop" << endl;
- getline(infile, buffer, '.');
- buffer[0] = toupper(buffer[0]);
- for (int i=1; i<buffer.size(); i++)
- buffer[i] = tolower(buffer[i]);
- buffer = buffer + '.';
- cout << buffer << endl;
- outfile << buffer;
- }
- infile.close();
- outfile.close();
- return 0;
- }
- output.txt
- I want you too know that no matter what ill alwayzzzzzzzzzzzzzzzzzzzz diiiiii ddddie dayyyyy dae dieee dei die die die die.
- input.txt
- 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