Skip to content

Conversation

@gthcbr25
Copy link

No description provided.

s->size = newSize;
}

void stringInsert(TString *s, size_t pos, TString toInsert) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавьте тесты в файл по образцу, чтобы протестировать новую функцию

}

void stringInsert(TString *s, size_t pos, TString toInsert) {
if (pos >= s->size) return;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В таком случае стоит поставить ошибку перед завершением. Используйте clearError и setError

s->data[i] = toInsert.data[i - pos];
}
for (size_t i = pos + substringLength; i < newSize; ++i) {
s->data[i] = secondPartCopy.data[i - substringLength - pos];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s->data не вместит в себя обе строки, если capacity < newSize. Возможно стоит использовать stringSubstring, stringConcat или же прописать логику расширения буффера строки самостоятельно

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants