Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main()
- {
- ifstream i;
- ofstream o;
- i.open("in.txt");
- o.open("o.txt");
- char buff; //buffer for the text we grab from the file
- int counted = 0, skipped = 0; //counters
- while(!i.eof()) {
- i.get(buff);
- //Series of statements to check what to write and how to write it
- if(buff >= 'a' && buff <= 'z') {
- o.put(buff);
- }
- else if(buff >= 'A' && buff <= 'Z') {
- buff+= 32;
- o.put(buff);
- }
- else if(buff == '\n') {
- o.put(buff); //alternative code: o.put('\n'); o.put('\n');
- o.put(buff);
- }
- else if(buff == ' ') { //spaces count as a delimiter, so unless you add one purposely it won't be put into the file
- o.put(' ');
- }
- else if(buff == '\t') {
- o.put(' ');
- }
- else {
- skipped++;
- }
- counted++;
- }
- cout << skipped << " characters were not put into the new file.";
- }
Add Comment
Please, Sign In to add comment