Why do we get a segmentation fault while performing any operation on an uninitialized pointer ?
[HASHTAG]#include[/HASHTAG]<stdlib.h>
[HASHTAG]#include[/HASHTAG]<string.h>
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]<string.h>
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 .
0