aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojtek Kosior <kwojtus@protonmail.com>2019-12-30 23:40:08 +0100
committerWojtek Kosior <kwojtus@protonmail.com>2019-12-30 23:40:08 +0100
commita2885ace9af6b78172837734ddd3a0ea269e1734 (patch)
tree460457adb5fda96184eaead2ffff2ad9196e6bfc
parent6421fd0e09448ed9134dab3338cfdda848a8eeaa (diff)
downloadrpi-MMU-example-a2885ace9af6b78172837734ddd3a0ea269e1734.tar.gz
rpi-MMU-example-a2885ace9af6b78172837734ddd3a0ea269e1734.zip
fix number trimming
-rw-r--r--strings.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/strings.c b/strings.c
index 34c269a..fb3b0ac 100644
--- a/strings.c
+++ b/strings.c
@@ -47,12 +47,12 @@ void uint32_to_binstring(uint32_t number, char buf[33])
void trim_0s(char string[])
{
size_t i;
- for (i = 0; string[i] != '\0' && string[i] != '0'; i++);
-
+ for (i = 0; string[i] == '0'; i++);
+
size_t j = 0;
- if (string[i] == '\0')
- string[j++] = string[i--];
+ if (!string[i])
+ string[j++] = string[--i];
do
string[j] = string[i + j];