feat(string): implemented pop function
This commit is contained in:
parent
6641181e0a
commit
107f8cc416
3 changed files with 16 additions and 1 deletions
|
|
@ -43,4 +43,6 @@ FledastyError fledasty_string_insert_at_index(FledastyString *current_string, co
|
|||
FledastyError fledasty_string_insert_before_string(FledastyString *current_string, char *before_character_string, const size_t before_character_string_size, char *character_string, const size_t character_string_size);
|
||||
FledastyError fledasty_string_insert_after_string(FledastyString *current_string, char *after_character_string, const size_t after_character_string_size, char *character_string, const size_t character_string_size);
|
||||
|
||||
FledastyError fledasty_string_pop(FledastyString *current_string);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -154,3 +154,14 @@ FledastyError fledasty_string_insert_after_string(FledastyString *current_string
|
|||
|
||||
return FLEDASTY_ERROR_VALUE_NOT_FOUND;
|
||||
}
|
||||
|
||||
FledastyError fledasty_string_pop(FledastyString *current_string) {
|
||||
if (current_string == NULL) {
|
||||
return FLEDASTY_ERROR_INVALID_POINTER;
|
||||
}
|
||||
|
||||
current_string->size -= 1;
|
||||
current_string->character_string[current_string->size] = '\0';
|
||||
|
||||
return FLEDASTY_ERROR_NONE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -293,6 +293,8 @@ int main() {
|
|||
printf("%s\n", normal_test_string.character_string);
|
||||
fledasty_string_insert_after_string(&normal_test_string, "nd", 2, "Bye", 3);
|
||||
printf("%s\n", normal_test_string.character_string);
|
||||
fledasty_string_pop(&normal_test_string);
|
||||
printf("%s\n", normal_test_string.character_string);
|
||||
|
||||
fledasty_string_free(&normal_test_string);
|
||||
printf("Done\n");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue