Comparing two anagrams in C This is a simple attempt by me to test whether two words are anagrams or not:

#include &lt;stdio.h&gt;
#include &lt;ctype.h&gt;

#define CH_LEN 15
#define N 26

int main(void) {
    char track_letters[N] = {0};
    char first_word[CH_LEN];
    char sec_word[CH_LEN];
    printf("Enter first word: ");
    int i;
    for(i = 0; i &lt; CH_LEN; i++) {
        first_word[i] = getchar();
        if(first_word[i] == '\n')
            break;
        if(!isalpha(first_word[i]))
            --i;

        track_letters[(tolower(first_word[i]) - 'a')]++;


    }
    printf("Enter second word: ");
    for(i = 0; i &lt; CH_LEN; i++) {
        sec_word[i] = getchar();
        if(sec_word[i] == '\n')
            break;
        if(!isalpha(sec_word[i]))
            --i;
        track_letters[(tolower(sec_word[i]) - 'a')]--;

    }
    for(i = 0; i &lt; CH_LEN; i++) {
        if(track_letters[i] != 0) {
            printf("The words are not anagrams");
            return 0;
        }
    }
    printf("The words are anagrams");

    return 0;
}


You can use any method of C (structure, pointers, functions etc.).
You limit yourself to anagrams of 15 letters.

#define CH_LEN 15
char first_word[CH_LEN];
char sec_word[CH_LEN];


But you don't actually use words after they are input.
You can fix the limitation (and a potentially serious bug) by not using the concept of a line. Just read characters.

In the code just read characters:

char nextInput = getchar();


No all alphabets are 26 letters.

#define N 26


I would have done this for clarity to show that you are looking at a-z:

#define N  ('z' - 'a' + 1)


Also N is not that descriptive. Personally I would have preferred a global static variable.

static const AlphabetSize = ('z' - 'a' + 1);


You basically repeat the same piece of code twice. This violates the DRY principle. Remove this code into a function and call the function passing parameters for the differences.

    int i;
    for(i = 0; i &lt; CH_LEN; i++) {
        first_word[i] = getchar();
        if(first_word[i] == '\n')
            break;
        if(!isalpha(first_word[i]))
            --i;

        track_letters[(tolower(first_word[i]) - 'a')]++;


    }
    printf("Enter second word: ");
    for(i = 0; i &lt; CH_LEN; i++) {
        sec_word[i] = getchar();
        if(sec_word[i] == '\n')
            break;
        if(!isalpha(sec_word[i]))
            --i;
        track_letters[(tolower(sec_word[i]) - 'a')]--;

    }


I would write like this:

    ProcessesAnagram(track_letters, +1);  // Reads first Line
    ProcessesAnagram(track_letters, -1);  // Reads second line


Since we are not longer bound by a word size. I would change the loop to check for the end of line (or end of input)).

 void ProcessesAnagram(int* track_letters, int increment)
 {
    int nextLetter = getchar();
    for(;nextLetter != EOF &amp;&amp; nextLetter != '\n'; nextLetter = getchar())
    {
        if(!isalpha(nextLetter)
        {    continue;           // If not a letter just start the next iteration
        }

        // Note: increment is +1 first anagram
        //       increment is -1 second anagram (so they will cancel out)
        track_letters[(tolower(nextLetter) - 'a')] += increment;    
    }
 }


There is a bug here

You are using the wrong size: CH_LEN is the size of the words. But the track_letters array has a size of N.

    for(i = 0; i &lt; CH_LEN; i++) {
        if(track_letters[i] != 0) {
            printf("The words are not anagrams");
            return 0;
        }
    }