What is SEGMENTATION FAULT? In which conditions does it occur?
Why did the following program receive the above error?
#include<unistd.h>
#include<errno.h>
#include<stdlib.h>
void main()
{
char *ptr="error",ptr1,ptr2;
int filedes[2];
pipe(filedes);
perror(ptr);
ptr1=malloc(1024);
scanf("%s",ptr1);
write(filedes[1],ptr1,1024);
ptr2=malloc(1024);
read(filedes[1],ptr2,1024);
printf("\n%s",ptr2);
free(ptr1);
free(ptr2);
}
Thanks in advance.
Avijit Lahiri