How can i understand the code char*a[3]? Does it mean declaring an array which can hold addresses of three characters?
#include <stdio.h>
int main(void)
{
char *a;
scanf("%s",a);
printf("%s \n",a);
return 0;
}
The above code does not work gives the output
(null)
I understand it is because the the declared pointer is pointing to nothing Then I ran the following code:
#include <stdio.h>
int main(void)
{
char *a[1];
scanf("%s",a[0]);
printf("%s \n", a[0]);
return 0;
}
This one works perfectly and can take indefinite amount of string length. Why is that?