Below program works:
int main()
{
char *g[10];
char a[10] = "test";
g[0] = &a[0];
printf("string = %s\n",g[0]);
exit(0);
}
output : test
But this does not work:
int main()
{
char t[] = "test";
struct abc
{
char *a[255];
}*p;
p->a[0] = &t[0];
printf("value = %s\n", p->a[0]);
exit(0);
}
output : segmentation fault
Can somebody tell what may be problem in second part of code? Sorry if i have post here wrongly.