diff options
author | Wojtek Kosior <kwojtus@protonmail.com> | 2019-12-30 23:40:08 +0100 |
---|---|---|
committer | Wojtek Kosior <kwojtus@protonmail.com> | 2019-12-30 23:40:08 +0100 |
commit | a2885ace9af6b78172837734ddd3a0ea269e1734 (patch) | |
tree | 460457adb5fda96184eaead2ffff2ad9196e6bfc | |
parent | 6421fd0e09448ed9134dab3338cfdda848a8eeaa (diff) | |
download | rpi-MMU-example-a2885ace9af6b78172837734ddd3a0ea269e1734.tar.gz rpi-MMU-example-a2885ace9af6b78172837734ddd3a0ea269e1734.zip |
fix number trimming
-rw-r--r-- | strings.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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]; |