Skip to content

Instantly share code, notes, and snippets.

@jnguyen1098
Created March 30, 2021 04:12
Show Gist options
  • Save jnguyen1098/9fb3ce9fa3b39df8c527a378ea8cd2a6 to your computer and use it in GitHub Desktop.
Save jnguyen1098/9fb3ce9fa3b39df8c527a378ea8cd2a6 to your computer and use it in GitHub Desktop.
Find out if two words are anagrams, bogo style
#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