In the following code I am having the output like(last one giving segmentation fault)
U
s
HelloThisisatest
Segmentation fault (core dumped)
but i do not understand why. code is
int main()
{
char *a[]={"Hello" "This" "is" "a" "test"};
printf("%c\n",a[1][0]);
printf("%c\n",a[0][8]);
printf("%s\n",a[0]);
printf("%s\n",a[3]);
return 0;
}
Another question is that can we initialize an 2-D array without using comma?
Another situation that I got that when i am replacing the \n
s by \t
s then output changes like
"U s HelloThisisatest (null)"
why?