From b723892dc0a60f9280133f39c8cbe7394988e4ac Mon Sep 17 00:00:00 2001 From: Jake Masters Date: Wed, 17 Jul 2019 15:01:17 -0500 Subject: [PATCH] Finished implementing int_to_ascii I've been following along with your tutorials, and I noticed that your int_to_ascii function still needs to reverse the contents of the string it populates. I implemented some code that reverses the string in place and tested it. Hopefully this is helpful, thank you so much for your awesome tutorials! --- 18-interrupts/kernel/util.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/18-interrupts/kernel/util.c b/18-interrupts/kernel/util.c index d7c5da7..2e0abf5 100644 --- a/18-interrupts/kernel/util.c +++ b/18-interrupts/kernel/util.c @@ -26,5 +26,15 @@ void int_to_ascii(int n, char str[]) { if (sign < 0) str[i++] = '-'; str[i] = '\0'; - /* TODO: implement "reverse" */ + // reverse + char aux_char = 0; + unsigned int front_index = 0; + unsigned int back_index = strlen(str)-1; + while(front_index < back_index){ + aux_char = str[front_index]; + str[front_index] = str[back_index]; + str[back_index] = aux_char; + front_index++; + back_index--; + } }