Advertisement
SergeyPGUTI

8.1.5

Feb 14th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <string.h>
  4.  
  5.  
  6. using namespace std;
  7.  
  8. void trimRight(char a[])
  9. {
  10.     int length=strlen(a);
  11.     for (int i=length-1;a[i]==' ';i--)
  12.     {
  13.         if (a[i-1]!=' ') a[i]=0;
  14.     }
  15. }
  16.  
  17. int main()
  18. {
  19.     char str[30]="asdas  dasda       ";
  20.     trimRight(str);
  21.     strcat(str,"OK");
  22.     cout<<str;
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement