Это целая функция. По сути, я пытался стереть некоторые слова из предложения. Я испытываю, когда программа достигает первой строки strcat.
Я действительно понятия не имею, в чем здесь проблема? Я неправильно использовал указатели?
РЕДАКТИРОВАТЬ: я пытаюсь это:
void reset_array(char* word,int n)
{
for (int i = 0; i < n; i++)
word[i] = 0;
}
void change_sentence(char* new_sentence, char* sentence, int n)
{
while (new_sentence!=EMPTY)
{
*sentence = *new_sentence;
sentence++; new_sentence++;
}
}
void delete_words(char * words[], int n, char * sentence)
{
char* sen_copy = sentence; bool first = true;
char* new_sentence = (char*)malloc(sizeof(char)*strlen(sentence)+1);
reset_array(new_sentence, strlen(sentence) + 1);
char* new_sentence_copy = new_sentence;
while (*sen_copy)
{
char current_word[MAX_LEN];
reset_array(current_word,MAX_LEN);
int i = 0;
while (*sen_copy && *sen_copy != WORD_SEPERATOR)
{
current_word[i] = *sen_copy;
i++;
sen_copy++;
}
if (!is_string_in_array(words, n, current_word))
{
if (!first)
{
*new_sentence_copy = WORD_SEPERATOR;
new_sentence_copy++;
}
int count = 0;
while (count < i)
{
*new_sentence_copy = current_word[count];
count++;
new_sentence_copy++;
}
first = false;
}
if (*sen_copy == WORD_SEPERATOR)
sen_copy++;
}
printf("Hi");
change_sentence(new_sentence, sentence, strlen(sentence) + 1);
free(new_sentence);
}
Я получаю тот же код ошибки.
Что вызывает ошибку сейчас? Разрешено ли мне менять предложение? Я думал, что вы могли бы сделать это, если это массив.