Hello can I get a help on this please, The program complied and ran , it worked and outputed something on the first file , but I get errors saying
[code]
Program received signal EXC_BAD_ACCESS, Could not access memory.
Code:
int main(int argc , char **argv[]) {
int i = 0 ;
int sir_count = 0; // for counting sir and sirs
for(i = 0; i < argc; i++) {
if( strcmp( argv[i] , "Sir") == 0 ) { // counting sir
++sir_count;
}
if( strcmp( argv[i] , "Sirs") == 0 ) { // counting sirs
++sir_count;
if( strcmp( argv[i+2] , "and") == 0 ) {
++sir_count;
}
if( strcmp( argv[i+1][ strlen( argv[i+1] )-1 ] , "," ) == 0 ) {
++sir_count;
if( !strcmp( argv[i+3] , "and") ==0 ) {
++sir_count;
}
}
}
}
printf("The number of Sir/Sirs in the file is : %d ", sir_count );
return EXIT_SUCCESS;
}