#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct BoundedArray
{
int SIZE;
char **words;
} boundedArray;
{
boundedArray *bArr = malloc(sizeof(boundedArray));
bArr->words = malloc(sizeof(char)*10001); char *tok = strtok (str,&delimiter);
while(tok!=NULL)
{
bArr->words [barr->SIZE] = malloc(sizeof(char)*10001 );
strcpy(bArr->words [bArr->SIZE++], tok);
tok= strtok (NULL,&delimiter);
}
return bArr;
}
int main ()
{
char str[1001], delimiter;
scanf("%s\n%c",str,delimiter) ;
boundedArray *bArr = customSplit (str, delimiter);
printf ("Words:\n");
for (int index = 0; index < bArr->SIZE; index++)
{
printf ("%s\n", bArr->words[index]);
} return 0;
}
0 Comments