summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ch2/2-03.c2
-rw-r--r--ch2/2-04.c8
-rw-r--r--ch2/2-05.c4
-rw-r--r--ch2/2-10.c2
4 files changed, 8 insertions, 8 deletions
diff --git a/ch2/2-03.c b/ch2/2-03.c
index 54ce89f..0376484 100644
--- a/ch2/2-03.c
+++ b/ch2/2-03.c
@@ -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;
diff --git a/ch2/2-04.c b/ch2/2-04.c
index 3f122bb..00501ca 100644
--- a/ch2/2-04.c
+++ b/ch2/2-04.c
@@ -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];
diff --git a/ch2/2-05.c b/ch2/2-05.c
index 495473c..282786e 100644
--- a/ch2/2-05.c
+++ b/ch2/2-05.c
@@ -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;
diff --git a/ch2/2-10.c b/ch2/2-10.c
index 3c6b0cc..e630718 100644
--- a/ch2/2-10.c
+++ b/ch2/2-10.c
@@ -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';