Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. char** word_list;
  2. word_list = (char**)malloc(words_num * sizeof(char*));
  3.  
  4. int x = 0; //number of words
  5. int y = 0; //number of characters
  6. char word[21] = " "; //initializing the word so the unused characters will be spaces
  7. for (size_t i = 0; i < strlen(char_list); i++) //a loop that goes threw the whole characters
  8. {
  9. if (isalpha(char_list[i])) {
  10. word[y] = char_list[i]; //the "word" will hold the characters and than intisialize the string at once
  11. y++;
  12. }
  13. if (char_list[i] == " " && isalpha(char_list[i + 1])) {
  14. word_list[x] = malloc(21);
  15. word_list[x] = word;
  16. x++;
  17. y = 0;
  18. word[16] = " ";
  19. }
  20. }
  21. return word_list;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement