Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char** word_list;
- word_list = (char**)malloc(words_num * sizeof(char*));
- int x = 0; //number of words
- int y = 0; //number of characters
- char word[21] = " "; //initializing the word so the unused characters will be spaces
- for (size_t i = 0; i < strlen(char_list); i++) //a loop that goes threw the whole characters
- {
- if (isalpha(char_list[i])) {
- word[y] = char_list[i]; //the "word" will hold the characters and than intisialize the string at once
- y++;
- }
- if (char_list[i] == " " && isalpha(char_list[i + 1])) {
- word_list[x] = malloc(21);
- word_list[x] = word;
- x++;
- y = 0;
- word[16] = " ";
- }
- }
- return word_list;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement