Description
Write a program that determines if two strings (words) are anagrams. The function (anagrams) should not be case-sensitive and should disregard any punctuation or spaces. Two strings are anagrams if the letters can be rearranged to form each other. For example, “state” is an anagram of “taste.” Each string contains one “s,” two “t’s,” etc. Test your function with several words that are anagrams and non-anagrams.
You must write the corresponding anagrams c file for the following anagrams.h file:
int anagrams (char str[], char strstr[]);
Your anagrams.c file must also work with the following main.c file:
#include
#include // for exit(1)
#include “anagrams.h”
int main(int args, char *argv[])
{
if (args == 3)
{
int ans = anagrams(argv[1], argv[2]);
if (ans) // anagrams
{
printf(“%s is an anagram of %s”, argv[1], argv[2]);
}
else
{
printf(“%s and %s are not anagram of each other”, argv[1], argv[2]);
}
} // end if
else
{
printf(“usage: ./a.out string1 string2\n”);
exit(1);
}
return 0;
—
Requirements:
– You are NOT allowed to use any predefined C function (string.h functions).
– You must write an appropriate Makefile
To submit your PDF and Java files on Moodle:
1. Create a folder with your last name.
2. Place your c file(s), header file(s) and makefile inside the folder.
3. Zip the folder.
4. Upload it to Moodle.
Sample Run:
./a.out State Taste
State is an anagram of Taste
./a.out state stat
state and stat are not anagram of each other