+ 1
Returns an array of string consisting of the characters in s split into tokens based on the delimeter c, followed by a
Suppose s is "I am ready for a nice vacation" and c is ' ', then I want return the arraylist {"I", "am", "ready", "for", "a", "nice", "vacation", NULL} I did the code below but it can not print out what I expect so is there someone who can help me to look at my code and fix it? Thanks https://code.sololearn.com/cb21G3FklJtV/#c
5 Respuestas
0
The problem is at line 13. You split by ',' character instead of space. With space all works fine.
There is also issue after line 50. You don't reset i counter and allocate more and more memory at each iteration.
It is also good to check all +1. I think some of them are not required or doubled.
0
are you willing to correct it?
0
Just use t-p instead of i.
0
i can not fix it? it still do not store into an array. Could you help me?
0
Tuyen Pham just fix line #13 by str_chop_all(s, ' ');