Advertisement
hopingsteam

Giulia strcpy

Nov 27th, 2019
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include    <iostream>
  2. #include    <cstring>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     char s[201] = "in vacanta    plec la          mare";
  9.  
  10.     //cin.get(s,101);
  11.     cout << "S este: " << s << "\n\n";
  12.     for(int i = 0; i < strlen(s); i++)
  13.     {
  14.         if(s[i] == ' ' && s[i+1] == ' ')
  15.         {
  16.  
  17.             //strcpy(s+i, s+i+1);
  18.            
  19.             char aux[201];
  20.             strcpy(aux, s+i+1);
  21.             strcpy(s+i, aux);
  22.  
  23.             cout << "[DEBUG]: " << s << "\n";
  24.             cout << "[DEBUG]: " << i << "\n\n";
  25.             i = i - 1;
  26.         }
  27.     }
  28.     cout << s;
  29.     cout << "\n";
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement