summaryrefslogtreecommitdiff
path: root/words.c
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-06-14 21:44:44 -0600
committermo khan <mo.khan@gmail.com>2020-06-14 21:44:44 -0600
commitfd9bfc42af1ae0a070558524d7e384eede8d9083 (patch)
tree8dfeb1325db8779e01354e3991de93fd71fd0f30 /words.c
parenta69ec51d000e090fa185f6035864b5f79a5fb98b (diff)
Add another test
Diffstat (limited to 'words.c')
-rw-r--r--words.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/words.c b/words.c
index 4d72a03..b9c236a 100644
--- a/words.c
+++ b/words.c
@@ -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++;
}
}