//Include files #include #include #include #include #include //Program void main(int argc, char* argv[]) { //Check the number of inputs if(argc != 2) { cout << "You forgot to enter a file name." << endl; return; } //Open the input file FILE* infile; infile = fopen(argv[1], "r"); if(infile == NULL) { cout << "The input file does not exist." << endl; return; } //Open the output file FILE* outfile; outfile = fopen("lprint.out", "w"); if(outfile == NULL) { cout << "Problem opening the output file." << endl; return; } //Loop over each line of the input file while(1) { //Read in a line char inlin[256]; char* ok; ok = fgets(inlin, 255, infile); if(ok == NULL)break; //Add spaces to the beginning of the line char outline[256]; strcpy(outline, " "); strcat(outline, inlin); //Write the shifted line to the output file fputs(outline, outfile); //End loop over input file lines } //Close the input file fclose(infile); //Close the output file fclose(outfile); //Short delay before print delay(7000); //Print the output file char print_command[256]; strcpy(print_command, "print "); strcat(print_command, "lprint.out"); cout << print_command << endl; system(print_command); //Wait until the output file is done printing //cout << "Printing " << argv[1] << "..." << endl; for(int i = 1; i < 26; i++) { delay(1000); printf(" %i", i); } //Done return; }