summaryrefslogtreecommitdiff
path: root/string_shit.cpp
blob: 4df25034912f3562c7a5fdf6ad5054849f886338 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdio.h>
#include <iostream>
#include <bits/stdc++.h>
#include <string>

using namespace std;
int main() {
  string input;
  string input_mod;
  while(true) {
    cout << "\nType in a string.\n";
    getline(cin, input);

    input_mod = input;
    reverse(input_mod.begin(), input_mod.end());
    cout << "\nString in reverse order:\t\t\t\t" << input_mod << "\n";


    cout << "Number of characters in string:\t\t\t\t" << input.length() << "\n"; 

    input_mod.erase(remove_if(input_mod.begin(), input_mod.end(), ::isspace), input_mod.end());
    cout << "Number of characters in the string, excluding spaces:\t" << input_mod.length() << "\n";

    cout << "Would you like to exit? (y/n)\n";
    getline(cin, input);
    if(input.at(0) == 'y'){
      return 0;
    }

  }
}