Advertisement
evcamels

lr-3-19

Nov 17th, 2020
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. class MyString{
  5. string str;
  6. public:
  7. MyString(string s){
  8. str = s;
  9. if(sizeof(s) % 2 != 0){
  10. space();
  11. }
  12. }
  13. void space() {
  14. for(int i=0;i<sizeof(str);i++){
  15. cout << str[i];
  16. if(str[i] == ' '){
  17. break;
  18. }
  19. }
  20. }
  21. ~MyString(){
  22. str[0] = 0;
  23. }
  24.  
  25. };
  26. int main() {
  27. char sentense[50];
  28. ifstream fin("file.txt");
  29. fin.getline(sentense, 50);
  30. fin.close();
  31. MyString str(sentense);
  32. return 0;
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement