0
내 save_words 함수는 armazena와 size를받습니다. Armazena는 단락을 포함하는 동적 배열이고 크기는 배열의 크기입니다. 이 함수에서는 단어라고하는 다른 동적 배열에 단어를 넣고 싶습니다. 내가 그것을 실행할 때, 그것은 충돌한다. 귀하의 도움에 감사드립니다.C 언어 -> 단락에서 단어 분리
char **save_words(char **armazena, int *size)
{
char *token = NULL;
char** armazena_aux = armazena;
int i, count=0;
char **words = (char**) malloc(sizeof(char*)*(10));
for(i=0; i<size; i++)
{
token = strtok(*(armazena+i)," .?!,");
while(token != NULL)
{
int tam = strlen(token);
armazena[count] = (char*) malloc(tam+2);
strcpy(armazena[count],token);
armazena[count][tam+1]='\0';
count++;
token = strtok(NULL, " .?!,");
if (count%10==0)
{
words = realloc(words, sizeof(char*)*(count + 10));
}
}
}
return words;
}
"디버거를 사용합니다. –
'for (i = 0; i
sjsam
'save_words'를 호출하는 코드에 문제가있을 수 있습니다. –