okay, so i'm totally new to this.
the purpose of my assignment is to compare two strings and to see if they're anagrams
my problem is that when i run it, it compiles okay, but then i'd get a message from windows, saying that it has stopped working.
er, yeah. i've no clue whats wrong, so any help would be appreciated.


char *string1[100000], *string2[100000];
int a, b, c, count1[27], count2[27], m, no;

int main () {
    for (m=0; m<=26; m++){
    for (a=0; a<=strlen(*string1); a++){
        if (isalpha(*string1[a]))
    for (b=0; b<=strlen(*string2); b++){
        if (isalpha(*string2[b]))
    for (c=0; c<=26; c++){
        if (count1[c]+count2[c]!=0)
    if (no==0)
    return 0;

For starters, instead of

char *string1[100000], *string2[100000];

you'll be doing much better of with something like

#define MAX_STRING_LEN 123 // define some reasonable string length
                           // 100000 really is not in that category, I think
char string1[MAX_STRING_LEN] = "";
char string2[MAX_STRING_LEN] = "";

Then after you've gotten the user's input for both strings,
sort the characters in the strings (i.e. "acb" becomes "abc"),
and compare the two sorted strings using e.g. strcmp() or strcmpi().
If they compare equal, it's an anagram (maybe given with the exception that they don't compare equal unsorted)
About getting the user's input, instead of gets(), see

char *string1[100000], *string2[100000];  // You just created 
                          // an arrayof 100000 POINTERs not a 
                          // string of 100000 characters

int a, b, c, count1[27], count2[27], m, no;

int main () {
    for (m=0; m<=26; m++){
        count1[m]=0;         // Now you set all the POINTERs to 0
    gets(*string1);          // read in something into a buffer 
                             // pointed to by the address of 
                             // STRING1.  On other words, 
                             // somewhere in Never-Never Land

What you want, as mitrmkar explains, is to create an array of chars, not and array of pointers. He also is correct -- 100000 is much too large. Unless you are planning on typing in a novel.

Also, see this about gets()

This article has been dead for over six months. Start a new discussion instead.