I have been attempting to iterate through a predetermined array of characters and compare it to a scanned in single char. If the scanned char is in the array I want to add it into a 2d array if it isn't in the array I want error handling.
My code is currently
    char c;
    char legalChar[] = "./\\=@ABCDEFGHIJKLMNOPQRSTUVWXYZ\n";
    int rowCount = 0;
    int colCOunt = 0;
    int i = 0;
    FILE * map;
    while (c = fgetc(map), c != EOF) {
        while (i < (sizeof(legalChar))){
            if (c == legalChar[i]){
                if (c == '\n'){
                    /*Add 1 to number of rows and start counting columns again */
                    rowCount++;
                    colCount = 0;
                }
                else {
                    /*would have code to add char to 2d array here */
                    colCount++;
                }
            }
        i++;
    }
I planned to have
    if (c != legalChar[i]){
        /*Error handling */
    }
but this doesn't work because it just jumps into this if statement on every iteration.
The output from the program at the moment is colCount gets assigned 1 and rowCount stays at 0. All chars that are iterated through are inside of the legalChar[] array so I'm not sure what I'm doing wrong.
Any advice would be greatly appreciated.
Thanks
 
     
     
    