This repository has been archived on 2023-05-13. You can view files and clone it, but cannot push or open issues or pull requests.
mipt_cpp/seminar03_initialization/04_truncate_to_dot/main.cpp

23 lines
417 B
C++
Raw Normal View History

2022-10-22 18:26:37 +03:00
#include <iostream>
#include <string>
using namespace std;
void truncateToDot(string& s) {
s.resize(s.find('.'));
s.shrink_to_fit();
}
int main() {
std::string a = "cat.dog.mouse.elephant.tiger.lion";
std::string b = "wikipedia.org";
std::string c = ".com";
truncateToDot(a);
truncateToDot(b);
truncateToDot(c);
cout << a << endl
<< b << endl
<< c << endl;
}