daily pastebin goal
41%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     ifstream i;
  8.     ofstream o;
  9.     i.open("in.txt");
  10.     o.open("o.txt");
  11.  
  12.     char buff;                          //buffer for the text we grab from the file
  13.     int counted = 0, skipped = 0;       //counters
  14.  
  15.     while(!i.eof()) {
  16.         i.get(buff);
  17.  
  18.         //Series of statements to check what to write and how to write it
  19.         if(buff >= 'a' && buff <= 'z') {
  20.             o.put(buff);
  21.         }
  22.         else if(buff >= 'A' && buff <= 'Z') {
  23.             buff+= 32;
  24.             o.put(buff);
  25.         }
  26.         else if(buff == '\n') {
  27.             o.put(buff);                //alternative code: o.put('\n'); o.put('\n');
  28.             o.put(buff);
  29.         }
  30.         else if(buff == ' ') {          //spaces count as a delimiter, so unless you add one purposely it won't be put into the file
  31.             o.put(' ');
  32.         }
  33.         else if(buff == '\t') {
  34.             o.put(' ');
  35.         }
  36.         else {
  37.             skipped++;
  38.         }
  39.         counted++;
  40.     }
  41.  
  42.     cout << skipped << " characters were not put into the new file.";
  43. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top