The following is a simple program that reads a .dat file that i included below. when i gcc compile from a windows command line everything works fine when i run the exe but when i run from a unix cmd line..... ".out" i get a segmentation fault. Why is this the case
#include<stdio.h>
int main(){
    FILE *fp;
    char ch;
    char c;
    char word[15];
    int count = 0;
    int a;
    int boolean_comma = 0;
    fp = fopen("lab1.dat","r");
    if( fp == NULL) {
        printf("ERROR");
    }else
        while(!feof(fp)){
            ch = fgetc(fp);
            word[count] = ch;
            /*printf("%c",word[count]);*/
            if(ch == ','){
                count -= 1;
                boolean_comma = 1;
            }/*END IF*/
            if(ch == ' '){
                if(count == 0){
                    count-=1;
                }
                if(count == 4 && boolean_comma == 1){
                    printf("****, ");
                }
                if(count == 4 && boolean_comma == 0){
                    printf("**** ");
                }/*END IF*/
                else{
                    if(boolean_comma != 1){
                        for(a = 0; a < count; a++){
                            c = word[a];            
                            printf("%c",c);
                        }/*END FOR*/
                    }
                    boolean_comma = 0;
                    printf(" "); 
                    count = 0;
                }/*END ELSE*/
                count = 0;
                /*END IF*/}
            else{
                count++;
            }/*END ELSE*/
            printf("%i",count);
        }/*END WHILE*/
    fclose(fp);
    return 0;
}//end main
FILE
p1data.dat
Mary had a little lamb, its fleas
as white as snow, And everywhere that Mary went, the
fleas were sure to go!
 
     
     
     
     
    