I need help writing an anagram that test 2 strings.
os: microsoft
compiler: visual studio
Here are some of the directions:
Read the first string, then write a loop that uses an array of 26 ints to count how many
times each letter has been seen.
Read the second string, this time decrement each letter’s count in the int array.
The strings are anagrams if every element in the int array is 0.
Ignore any characters that aren’t letters. Treat upper-case letters as the same as their
lower-case equivalent.
compiling errors:
warning C4013: 'initialize' undefined; assuming extern returning int
warning C4013: 'getString' undefined; assuming extern returning int
warning C4013: 'setLetters' undefined; assuming extern returning int
error C2371: 'initialize' : redefinition; different basic types
error C2371: 'getString' : redefinition; different basic types
error C2371: 'setLetters' : redefinition; different basic types
warning C4013: 'isalpha' undefined; assuming extern returning int
warning C4013: 'tolower' undefined; assuming extern returning int
What do these errors mean? basically i need help finishing my program.
this is what i have no far:
void checkLetters(int narray[], char carray[]);
int isZero(int narray[]);
void main(void)
{
int charNums[LETTERS], i = 1;
char word[MAX];
do
{
initialize(charNums,word);
printf("Enter your first statement: ");
getString(word);
setLetters(charNums, word);
printf("Enter your second statement(""Quit"" to quit): ");
getString(word);
checkLetters(charNums, word);
if(isZero(charNums))
printf("Anagram\n");
else
printf("Not Anagram\n");
if(!strcmp(word,"quit")||!strcmp(word, "Quit"))
i = FALSE;
}while(i);
}
void initialize(int narray[],char carray[])
{
int i;
for(i=0; i < LETTERS; ++i)
{
narray[i] = 0;
}
for(i=0; i<MAX; ++i)
{
carray[i] = '\0';
}
}
void getString(char carray[])
{
gets_s(carray, MAX - 1);
}
void setLetters(int narray[], char carray[])
{
int i = 0;
while(carray[i])
{
if(isalpha(carray[i]))
{
carray[i] = tolower(carray[i]);
narray[(int) (carray[i] - 'a')] += 1;
}
i++;
}
}
void checkLetters(int narray[], char carray[])
{
int i = 0;
while(carray[i])
{
if(isalpha(carray[i]))
{
carray[i] = tolower(carray[i]);
narray[(int) (carray[i]-'a')] -= 1;
}
i++;
}
}
int isZero(int narray[])
{
int i;
for(i=0; i < LETTERS; ++i)
{
if(narray[i] != 0)
{
return FALSE;
}
}
return TRUE;
}