Move the 'not' operator to the proper location

This commit is contained in:
Nick Chambers 2022-01-13 12:43:06 -06:00
parent a4000ec9b3
commit 201e9b0eae
1 changed files with 2 additions and 4 deletions

View File

@ -1,5 +1,3 @@
#include <stdio.h>
int match(const char *needle, const char *haystack) {
while(*haystack) {
if(*needle == '*' && *(needle + 1) == '*') {
@ -20,7 +18,7 @@ int match(const char *needle, const char *haystack) {
}
}
return *needle != '\0';
return *needle == '\0';
}
int main(int argc, char **argv) {
@ -28,5 +26,5 @@ int main(int argc, char **argv) {
return 1;
}
return match(argv[1], argv[2]);
return !match(argv[1], argv[2]);
}