int main() { char *html_buf, *buf, **tokens; const char delimiters[] = " "; int cnt; cnt = 0; tokens = NULL; if ( (html_buf = malloc(BUF_APP_Q)) == NULL) err_sys("malloc error"); if ( (buf = malloc(BUF_SIZE)) == NULL) { err_sys("malloc error"); } strcpy(html_buf, "tirini ta ta keke "); buf = strtok(html_buf, delimiters); while (buf != NULL) { if((tokens = realloc(tokens, (cnt+1) * sizeof(char *))) == NULL) err_sys("malloc error"); /* Prosekse oti einai * katw, oxi + an kai sumfwna me to iso sizeof(char) = 1 */ if( ( tokens[cnt] = malloc(strlen(buf) * sizeof(char)) ) == NULL ) err_sys("malloc error"); strcpy(tokens[cnt], buf); buf = strtok(NULL, delimiters); cnt++; } exit(0); }