when i try to run the program to make it just tell me how many characters are in a file i get a segmentation fault...
Code:
//Compares upto 100 files, and decides which one has the most characters(bytes) and which has the most words.
#include <stdio.h>
#include <stdlib.h>
int i;
int main(int argc,char **argv)
{
int c,w,n,max_char[n],max_words[n],numtotal,numwords;
char most_words,most_chars;
FILE *f[n],*g;
n=0;
numtotal=0;
for (i=1;i <= argc;i++){
f[n]=fopen(argv[i],"r");
if(f[n]==NULL){
printf("Can't open %s \n",argv[i]);
exit(0);
break;
}
else{
fgetc(f[n]);
while(c != EOF){
if(c==' '){
numwords++;
}
c=getc(f[n]);
}
}
n++;
exit(1);
}
printf("%d",c);
}