fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4.  
  5.  
  6. int main() {
  7. std::string string = ",.What, ., da,. heEAc,..,.k!?,";
  8.  
  9. auto const commaCount = std::count(std::begin(string), std::end(string), ',');
  10. std::replace(std::begin(string), std::end(string), ',', '.');
  11.  
  12. std::cout << string << std::endl;
  13. std::cout << commaCount << " comma(s) replaced with period(s)" << std::endl;
  14. }
  15.  
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
..What. .. da.. heEAc.....k!?.
7 comma(s) replaced with period(s)