Created
March 30, 2021 04:12
-
-
Save jnguyen1098/9fb3ce9fa3b39df8c527a378ea8cd2a6 to your computer and use it in GitHub Desktop.
Find out if two words are anagrams, bogo style
This file contains hidden or 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
#define _GNU_SOURCE | |
#include <stdio.h> | |
#include <string.h> | |
int main(void) | |
{ | |
char first_word[BUFSIZ] = ""; | |
char second_word[BUFSIZ] = ""; | |
printf("Enter two words to check if they're an anagram (separated by a space): "); | |
scanf("%s %s", first_word, second_word); | |
for (;;) { | |
char *scrambled = strfry(second_word); | |
if (!strcmp(first_word, scrambled)) { | |
puts("They are anagrams!"); | |
return 0; | |
} else { | |
puts("They might be..."); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment