[plug] [OT] segmentation fault
Richard
wpickett at iprimus.com.au
Thu May 30 13:48:56 WST 2002
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