(no subject)

B.J. Ernsting (breytene@htsa.hva.nl)
Tue, 07 Oct 1997 08:30:33 +0200


Abhijit Lahiri wrote:
>
> Hi All,
> I am new to Linux kernel.Will be thankfull if someone helps.
>
> 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", // I think this causes the problem
// try : char *ptr;
ptr1,ptr2;
> int filedes[2];
> pipe(filedes);
// strcpy(ptr,"error");
> 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);
>
> }
>
Breyten
> Thanks in advance.
> Avijit Lahiri
>
>
>