Hi, I use char* for string handling because I read strings from a file and I don't know the length of these strings. The problem comes when I need to keep some strings in an array. I think char** is the best thing for that goal. But again since I don't know how many strings I will hold, I'm stuck in allocating memory for new strings to be hold. For example;
char* str;
char** match_list;
while (fscanf(inp, "%s", str) != EOF) {
if (matches(str)) {
*match_list = (char**)malloc(sizeof(char*));
*(match_list + i) = str;
i++;
}
}
matches is the function checks the string for my intention. The line that malloc is included is a bit silly, I know :). I need to access the strings in future. I think I could explain my problem. I want to allocate a new char* space and bind my str to it. But how?
Thanks...