Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void Trim(char ch[101]);
  5.  
  6. int main()
  7. {
  8.     char ch[101];
  9.     cin.get(ch, 101);
  10.  
  11.     Trim(ch);
  12.  
  13.     for (int i = 0; ch[i]; ++i)
  14.         cout << ch[i];
  15. }
  16.  
  17. void Trim(char ch[101])
  18. {
  19.     int poz1 = 0;
  20.     while (ch[poz1] == ' ')
  21.         poz1++;
  22.  
  23.     int poz2 = 0;
  24.     while (ch[poz2])
  25.         poz2++;
  26.  
  27.     poz2--;
  28.     while (ch[poz2] == ' ')
  29.         poz2--;
  30.  
  31.     char t[101] = "";
  32.     char v[101] = "";
  33.     ch[101] = v[101];
  34.  
  35.     int x = poz2 - poz1;
  36.     for (int i = 0; i <= x; ++i)
  37.         t[i] = ch[poz1 + i];
  38.  
  39.     for (int i = 0; i <= x; ++i)
  40.         ch[i] = t[i];
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement