char p[3][6]={{'a','b','c','\0'},{'d','e','f','\0'},{'g','h','i','\0'}};
char s[3][6]={"abc","def","ghi"};
Are they both same? If different please explain what way and how it is stored in memory?
There is no difference in any of two methods, Try the following code and see the result
Result for both variables p and s are same.
#include<stdio.h>
void main()
{
int i,j=0;
char p[3][6]={{'a','b','c','\0'},{'d','e','f','\0'},{'g','h','i','\0'}};
char s[3][6]={"abc","def","ghi"};
for(i=0;i<3;i++)
{
printf("%s",p[i]);
printf("\n");
}
for(i=0;i<3;i++)
{
printf("%s",s[i]);
printf("\n");
}
}
Here is the result:
First 2-d string is : abc def ghi
Second 2-d string is :abc def ghi
char *c[3] = { "abc", "def", "ghi" }; is different. Worth noting.
char p[3][6]={{'a','b','c','\0'},{'d','e','f','\0'},{'g','h','i','\0' }};I think.-Wall...