diff options
author | Adam Carpenter <gitlab@53hor.net> | 2019-07-23 13:03:59 -0400 |
---|---|---|
committer | Adam Carpenter <gitlab@53hor.net> | 2019-07-23 13:03:59 -0400 |
commit | cbfba32803a16ebe6b33f8ccdedf602cc49addc7 (patch) | |
tree | 2787b016e1b4cb2c56c6fb57257126b2b3d594bd | |
parent | fa996dc786d26afc508d637c565ec401f6b5ddb9 (diff) | |
download | learning-c-cbfba32803a16ebe6b33f8ccdedf602cc49addc7.tar.xz learning-c-cbfba32803a16ebe6b33f8ccdedf602cc49addc7.zip |
Removed unecessary string terminator checks.
-rw-r--r-- | ch2/2-03.c | 2 | ||||
-rw-r--r-- | ch2/2-04.c | 8 | ||||
-rw-r--r-- | ch2/2-05.c | 4 | ||||
-rw-r--r-- | ch2/2-10.c | 2 |
4 files changed, 8 insertions, 8 deletions
@@ -8,7 +8,7 @@ unsigned int htoi(char hex[]) { int power; unsigned int result; - for (length = 0; hex[length] != '\0'; ++length) + for (length = 0; hex[length]; ++length) power = 1; result = 0; @@ -5,7 +5,7 @@ void squeeze_char(char s[], char c) { int i; int j; - for (i = j = 0; s[i] != '\0'; i++) + for (i = j = 0; s[i]; i++) if (s[i] != c) s[j++] = s[i]; @@ -16,7 +16,7 @@ void squeeze_char(char s[], char c) { void squeeze_str(char s1[], char s2[]) { int i; - for (i = 0; s2[i] != '\0'; ++i) + for (i = 0; s2[i]; ++i) squeeze_char(s1, s2[i]); } @@ -26,8 +26,8 @@ void squeeze_all(char s1[], char s2[]) { int j; int k; - for (k = 0; s2[k] != '\0'; ++k) { - for (i = j = 0; s1[i] != '\0'; ++i) + for (k = 0; s2[k]; ++k) { + for (i = j = 0; s1[i]; ++i) if (s1[i] != s2[k]) s1[j++] = s1[i]; @@ -4,8 +4,8 @@ int any(char s1[], char s2[]) { int i; int j; - for (i = 0; s2[i] != '\0'; ++i) - for (j = 0; s1[j] != '\0'; ++j) + for (i = 0; s2[i]; ++i) + for (j = 0; s1[j]; ++j) if (s2[i] == s1[j]) return j; @@ -16,7 +16,7 @@ int main() { void lower_str(char source[], char dest[]) { int i; - for (i = 0; source[i] != '\0'; i++) + for (i = 0; source[i]; i++) dest[i] = lower_char(source[i]); dest[i] = '\0'; |