Add option to print out list on new line or not

main
Hammy 3 years ago
parent 1841d34ed8
commit 265998a649

@ -259,8 +259,13 @@ int List_max_length(List *list) {
return list->_maxSize; return list->_maxSize;
} }
void List_print(List *list) { void List_print(List *list, bool new_line) {
printf("["); if (new_line) {
printf("\n[");
} else {
printf("[");
}
for (int i = 0; i < list->_currentSize + 1; i++) { for (int i = 0; i < list->_currentSize + 1; i++) {
if (i == list->_currentSize) { if (i == list->_currentSize) {
printf("%i", list->_array[i]); printf("%i", list->_array[i]);
@ -268,6 +273,7 @@ void List_print(List *list) {
printf("%i, ", list->_array[i]); printf("%i, ", list->_array[i]);
} }
} }
printf("]"); printf("]");
} }

@ -239,12 +239,13 @@ int List_max_length(List *list);
* Params * Params
* ---------------------------- * ----------------------------
* *list the list to print out * *list the list to print out
* new_line true if wanting to print on a new line, false if not
* *
* Returns * Returns
* ---------------------------- * ----------------------------
* void * void
*/ */
void List_print(List *list); void List_print(List *list, bool new_line);
/* /*
* *

Loading…
Cancel
Save