Guest User

Untitled

a guest
Dec 9th, 2019
120
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. * Copyright(c) 2019
  3. * Avesani Dennis
  4. * v9-12-2019
  5. *
  6. */
  7. #include<stdio.h>
  8.  
  9. int main() {
  10. char m[100][100];
  11. char s[100] = "Ciao come stai?\0";
  12. int i, lastSpace = 0, j = 0;
  13.  
  14. for(i = 0; s[i]; i++) {
  15. if(s[i] == ' ') { m[j][i-lastSpace] = 0; j++; lastSpace = i; }
  16. else m[j][i-lastSpace] = s[i];
  17. }
  18.  
  19. for(i = lastSpace; s[i]; i++) m[j][i-lastSpace] = s[i + 1];
  20.  
  21. m[j][i-lastSpace] = 0;
  22.  
  23. for(i = 0; i < 3; i++) printf("%s\n", m[i]);
  24.  
  25. return 0;
  26. }
RAW Paste Data