diff --git a/lib/string.c b/lib/string.c index 730750c..a573aa6 100644 --- a/lib/string.c +++ b/lib/string.c @@ -37,7 +37,7 @@ void string_replace(string_t string, char search, char replace) { string[string_length] = '\0'; } -void string_remove_character(char* string, char search) { +void string_remove_character(string_t string, char search) { size_t string_length = string_get_length(string); for (size_t index = 0; index < string_length; index++) { if (string[index] == search) { diff --git a/lib/string.h b/lib/string.h index a03a1b4..2a439f9 100644 --- a/lib/string.h +++ b/lib/string.h @@ -61,7 +61,7 @@ void string_replace(string_t string, char search, char replace); * @param search A character search value. * @since v4.1.0 */ -void string_remove_character(char* string, char search); +void string_remove_character(string_t string, char search); /** * @brief Removes all `character` from the start of a string. diff --git a/lib/terminal.c b/lib/terminal.c index 2590732..4ee3ca1 100644 --- a/lib/terminal.c +++ b/lib/terminal.c @@ -24,7 +24,7 @@ string_t terminal_input() { void terminal_print_array(void* array, size_t array_size, size_t element_size, void (*print_element)(void*)) { printf("["); for (size_t index = 0; index < array_size; index++) { - void* element = (char*)array + index * element_size; + void* element = (string_t)array + index * element_size; print_element(element); bool is_last = index == array_size - 1; if (!is_last) { @@ -47,11 +47,11 @@ void terminal_print_unsigned_long(void* value) { } void terminal_print_char(void* value) { - printf("%c", *(char*)value); + printf("%c", *(string_t)value); } void terminal_print_string(void* value) { - printf("%s", (char*)value); + printf("%s", (string_t)value); } void terminal_print_stack(struct stack* stack, void (*print_element)(void*)) { @@ -63,7 +63,7 @@ void terminal_print_stack(struct stack* stack, void (*print_element)(void*)) { struct stack_node* node_current = stack->first; while (node_current != NULL) { printf("|\t"); - void* element = (char*)node_current->data; + void* element = node_current->data; print_element(&element); node_current = node_current->next; printf("\t|\n"); @@ -79,7 +79,7 @@ void terminal_print_queue(struct queue* queue, void (*print_element)(void*)) { struct queue_node* node_current = queue->first; while (node_current != NULL) { printf("|\t"); - void* element = (char*)node_current->data; + void* element = node_current->data; print_element(&element); node_current = node_current->next; printf("\t|\n"); @@ -94,7 +94,7 @@ void terminal_print_linked_list(struct linked_list* linked_list, void (*print_el } struct linked_list_node* node_current = linked_list->head; while (node_current != NULL) { - void* element = (char*)node_current->data; + void* element = (string_t)node_current->data; node_current = node_current->next; print_element(&element); printf(" -> "); diff --git a/set_version.c b/set_version.c index be75e86..32d4c23 100644 --- a/set_version.c +++ b/set_version.c @@ -3,7 +3,7 @@ #include "libcproject.h" -int main(int argc, char** argv) { +int main(int argc, string_t* argv) { if (argc != 2) { fprintf(stderr, "Usage: %s \n", argv[0]); return EXIT_FAILURE; diff --git a/test/convert_test.c b/test/convert_test.c index b373fd6..85df3c8 100644 --- a/test/convert_test.c +++ b/test/convert_test.c @@ -10,7 +10,7 @@ void convert_test() { } void convert_character_to_string_test() { - char* result = convert_character_to_string('a'); + string_t result = convert_character_to_string('a'); assert(assert_string_equal(result, "a")); free(result); @@ -77,7 +77,7 @@ void convert_string_to_number_test() { } void convert_number_to_string_test() { - char* result = convert_number_to_string(0); + string_t result = convert_number_to_string(0); assert(assert_string_equal(result, "0")); free(result); @@ -143,7 +143,7 @@ void convert_number_to_string_test() { } void convert_number_from_base_to_another_test() { - char* result = convert_number_from_base_to_another("15", 10, 16); + string_t result = convert_number_from_base_to_another("15", 10, 16); assert(assert_string_equal(result, "F")); free(result); diff --git a/test/string_test.c b/test/string_test.c index fc7ba75..25800af 100644 --- a/test/string_test.c +++ b/test/string_test.c @@ -203,7 +203,7 @@ void string_get_is_substring_test() { } void string_get_formatted_number_test() { - char* result = string_get_formatted_number(1000, " "); + string_t result = string_get_formatted_number(1000, " "); assert(assert_string_equal(result, "1 000")); free(result); @@ -235,7 +235,7 @@ void string_get_formatted_number_test() { void string_get_last_occurence_of_character_test() { string_t string = "abcdef"; - char* result = string_get_last_occurence_of_character(string, 'a'); + string_t result = string_get_last_occurence_of_character(string, 'a'); assert(assert_string_equal(result, "abcdef")); free(result);