I am aware about the redundancy of the argument. Because of that, I would like to thank you all in advance for your patience.
I have thoughtfully read many good thread about the issue such as this and this. I have conceptually clear what core dumping is, but I cannot figure out what practically is and how to detect it.
Please consider the following example I am working on: it is a simple program that checks if an input string is a palindrome:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define SIZE 20
int length(char s[SIZE]){
int i;
while(s[i] != 0)
i++;
return i;
}
int main(){
char s[SIZE], c;
int i = 0, j, flag = 1;
printf("\n\nGood morning, master. Tell me a word. I will check if it is a\n"
"palindrome\n\n");
for(i = 0; (c = getchar()) != '\n'; ++i){
s[i] = c;
}
j = length(s) - 1;
while(flag && i < j){
flag = s[i] == s[j];
i++; j--;
}
if(flag)
printf("\n\nSuccess!\n\n");
return 0;
}
What does cause in this program "the core to bump?"