(no subject)

Iba\qez Palomar Juan David (al004151@llevant.uji.es)
Tue, 7 Oct 1997 12:09:24 +0200 (METDST)


>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",ptr1,ptr2; // The error is here
you declare ptr1 and ptr2 as char
it must be:

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
>