1: // Filename: SHIFTEXT.CPP 2: // Purpose: Indents all the lines in a textfile by 4 spaces. 4: #include <iostream> 5: #include <fstream> 6: #include <string> 7: using namespace std; 9: int main(int argc, char* argv[]) 10: { 11: if (argc != 3) 12: { 13: cout << "\nThis program shifts all the lines in " 14: << "a textfile 4 spaces to the right. \n\n" 15: << "Usage: \n" 16: << "shiftext source_file destination_file\n"; 18: return 1; 19: } 20: else 21: { 22: ifstream inFile(argv[1]); 23: ofstream outFile(argv[2]); 24: string line; 25: getline(inFile, line); 26: while (inFile) 27: { 28: line = " " + line; 29: outFile << line << endl; 30: getline(inFile, line); 31: } 32: inFile.close(); 33: outFile.close(); 34: } 36: return 0; 37: }