[plug] [OT] segmentation fault

Carl Gherardi C.Gherardi at curtin.edu.au
Thu May 30 13:46:06 WST 2002


I assume command has memory allocated to it?

> -----Original Message-----
> From: Richard [mailto:wpickett at iprimus.com.au]
> Sent: Thursday, May 30, 2002 1:49 PM
> To: plug at plug.linux.org.au
> Subject: Re: [plug] [OT] segmentation fault
> 
> 
> On Thu, 2002-05-30 at 13:40, Richard wrote:
> > I know this is a little OT, but it's starting to drive me nuts, so I
> > hope someone can help. I'm writing a small C program that takes
> > arguments (file names) off the command-line, prepends a 
> command using
> > strcat(command, argv[x]), and then creates a pipe to the command and
> > simply reads in and then prints out the results. When I run 
> the program
> > I keep getting segmentation fault errors. I have narrowed 
> it down the
> > the strcat(command, argv[x]) line, but I can't see any 
> problem with it.
> > Would any kind person like to offer a hint?
> > 
> > The exact line is next = strcat(command, argv[count + 1]);
> > 
> > Where next is an uninitialized char *,command has been 
> initialized to
> > "ls -l ", and count + 1 is definitely within bounds.
> > 
> > Any ideas would be very welcome.
> 
> P.S. I forgot to mention that the offending line is the first line of
> the for loop...
> 	for(count = 0; count < argc; count++)
> 	
>  
> 
> 



More information about the plug mailing list