前言
力扣还挺上道(bushi),今天第一次写每日一题,给了个简单等级的数组题,我只能说,首战告捷(小白的呐喊),看看这每日一题我能坚持一天写出来,
ok,那么王子公主请看题:
char** splitWordsBySeparator(char** words, int wordsSize, char separator, int* returnSize) {
char** p = (char**)calloc(2000, sizeof(char*));
*returnSize = 0;
for (int i = 0; i < wordsSize; i++)
{
char arr[2];
arr[0] = separator;
arr[1] = '\0';
char* ps = NULL;
char brr[101] = { 0 };
strcpy(brr, words[i]);
for (ps = strtok(brr, arr); ps != NULL; ps = strtok(NULL, arr))
{
p[(*returnSize)] = (char*)malloc(sizeof(char) * (strlen(ps)+ 1));
strcpy(p[(*returnSize)++], ps);
}
}
return p;
}