-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd4fc4c
commit 15e14cc
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
Binary file renamed
BIN
+9.05 KB
01-recurse_expand_and_print_file/a.out → 02-compare-strings-ignoring-noise-char/a.out
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
#define FALSE 0 | ||
|
||
int compareStrings(const char *str1, const char *str2, char noise){ | ||
while(str1[0] == noise) str1++; | ||
while(str2[0] == noise) str2++; | ||
|
||
if(str1[0] == '\0'){ | ||
return (str2[0] == '\0'); | ||
} | ||
else if(str2[0] == '\0'){ | ||
return FALSE; | ||
} | ||
else if(str1[0] == str2[0]){ | ||
return compareStrings(++str1, ++str2, noise); | ||
} | ||
return FALSE; | ||
} | ||
|
||
int main(int argc, char *argv[]){ | ||
if(argc < 4){ | ||
fprintf(stdout,"Usage: compare-strings [string 1] [string 2] [noise character]\n"); | ||
return 1; | ||
} | ||
|
||
fprintf(stdout, compareStrings(argv[1],argv[2],argv[3][0]) ? "The strings are equal.\n":"The strings are NOT equal.\n"); | ||
return 0; | ||
} |