diff options
| author | mo khan <mo.khan@gmail.com> | 2020-06-14 21:44:44 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2020-06-14 21:44:44 -0600 |
| commit | fd9bfc42af1ae0a070558524d7e384eede8d9083 (patch) | |
| tree | 8dfeb1325db8779e01354e3991de93fd71fd0f30 /words.c | |
| parent | a69ec51d000e090fa185f6035864b5f79a5fb98b (diff) | |
Add another test
Diffstat (limited to 'words.c')
| -rw-r--r-- | words.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -1,9 +1,11 @@ #include <string.h> int split_words(char *sentence) { - int i, count = 1; - for (i = 0; i < strlen(sentence); i++) { + int i, count = 1, length = strlen(sentence); + + for (i = 0; i < length; i++) { if (sentence[i] == ' ') { + sentence[i] = '\0'; count++; } } |
