Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <cstdlib>
- using namespace std;
- int main(){
- char in_filename[1024], out_filename[1024];
- system("clear");
- cout << "Enter the name of the input file: ";
- cin.getline(in_filename, 1024, '\n');
- cout << "Enter the name of the output file: ";
- cin.getline(out_filename, 1024, '\n');
- ifstream in(in_filename, ios::in);
- fstream out(out_filename, ios::in | ios::out | ios::trunc);
- if(!in){
- cout << "Could not open input file" << endl;
- return 1;
- }
- else{
- char ch;
- while(in.get(ch)){
- if(ch >= 'a' && ch <= 'z'){
- out.put(ch - 32);
- }
- else{
- out.put(ch);
- }
- }
- // Displaying the output file
- cout << "The contents of the output file is\n";
- out.seekp(0, ios::beg);
- while(out.get(ch)){
- cout << ch;
- }
- }
- in.close();
- out.close();
- return 0;
- }
Add Comment
Please, Sign In to add comment