Ok tamto zostało rozwiązanie teraz mam problem ze zwalnianiem pamięci po tablicy. Wyskakuje mi błąd.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define lenght 100
#define pointer_size 2
#define word_lenght 20
int main()
{
char white_chars[8] = " ,.-'\n'";
char **words =(char**) malloc(sizeof(*words));
words[0] = (char *)malloc(word_lenght * sizeof(**words));
char *token; // wskaznik na token, czyli adres tam gdzie ześmy skończyli. np zdanie :"p ha", po wykonaniu funkcji strtok token bedzie wskazywać na adres gdzie jest "h"
char sentence[lenght];
fgets(sentence, lenght, stdin);
printf("%s", sentence);
words[0] = strtok_s(sentence, white_chars, &token); // pobranie 1 słowa
printf("1: %s\n", words[0]);
int i = 0;
while (words[i] != NULL)
{
i++;
words = (char**)realloc(words, (i+1)*sizeof(*words));
words[i] = (char *)malloc(word_lenght * sizeof(**words));
words[i] = strtok_s(NULL, white_chars, &token);
if (words[i] != NULL)
{
printf("%d: %s\n", i + 1, words[i]);
}
else
{
words[i] = NULL;
}
}
getch();
return 0;
}