lkml.org 
[lkml]   [1997]   [Oct]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe:
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
>
>
>

\
 
 \ /
  Last update: 2005-03-22 13:40    [W:0.044 / U:1.632 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site