Advertisement
Guest User

Untitled

a guest
Nov 3rd, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. void subStr(char *src, char *out, int part) { /* subStr is a function that copies the "part"
  2. substring of src to out and returns out's
  3. address -- "parts" are strings seperated by spaces */
  4. int i = 0, j = 0;
  5.  
  6. while(part > 1) {
  7.  
  8. while(*(src + i++) != ' ') {} // cycle through bytes of src
  9.  
  10. part--; // decrease "part" by one for every space found
  11.  
  12. } // here we have reached the string we want to copy
  13.  
  14. while((*(src + i) != ' ') || (*(src + i) != '\0')) // copy till next space or end of string
  15. *(out + j++) = *(src + i++);
  16.  
  17. *(out + j) = '\0';
  18.  
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement