I have a long string and I want to take specific substrings of it and store it into an array of strings. I tried using malloc() with memcpy() but it doesn't seem to work. how would I go about doing this? code:
for(i = 0; i < strlen(p); i++){
if(p[i] == ':'){
cnt++;
end = i - start;
list[i] = malloc(1000);
memcpy( list[i], &p[start], end );
list[i][end] = '\0';
//printf("%s\n", list[i]);
start = i + 1;
}
}