From 5322c6f751b45e4fa55b527b46e16bd054ecc7a4 Mon Sep 17 00:00:00 2001 From: Jerry Qi <77580327+jerryq0101@users.noreply.github.com> Date: Mon, 21 Oct 2024 17:17:45 -0400 Subject: [PATCH] Make strend.c more concise --- chapter_5/exercise_5_04/strend.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/chapter_5/exercise_5_04/strend.c b/chapter_5/exercise_5_04/strend.c index 9094d86..a627939 100644 --- a/chapter_5/exercise_5_04/strend.c +++ b/chapter_5/exercise_5_04/strend.c @@ -37,11 +37,8 @@ int strend(char *s, char *t) // Check backwards if each character from string t occurs in the corresonding // location from the string s. - while (t_length && (*s-- == *t--)) + while (*s-- == *t--) --t_length; - if (t_length) - return 0; - - return 1; + return !t_length; }