[Solved] Segmentation Error in character array


First remove & from scanf.Like

scanf("%s", a);

char a[10] allocates the array on the stack for 10 char only. now when you enter characters as soon as you get out of bounds you are overwriting other useful things like the stack frame of the scanf call.

This out-of-bounds behavior is undefined by the C standard,

solved Segmentation Error in character array