radha
Member • Jul 26, 2015
Why do we get a segmentation fault while performing any operation on an uninitialized pointer ?
[HASHTAG]#include[/HASHTAG]
[HASHTAG]#include[/HASHTAG]
int main(void)
{
char *p ;
strcat(p, "abc");
printf("\n %s \n", p);
return 0;
}
If I print this the value at some random location pointed to by pointer , I get some garbage value so then there must be some compile-time error rather than segmentation fault ,plz clarify this .
[HASHTAG]#include[/HASHTAG]
int main(void)
{
char *p ;
strcat(p, "abc");
printf("\n %s \n", p);
return 0;
}
If I print this the value at some random location pointed to by pointer , I get some garbage value so then there must be some compile-time error rather than segmentation fault ,plz clarify this .