[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C stuff




Bill Dunn said:
> What would be the equivalent in ANSI C or C++ to the following PERL line:
>
> $input = `ls -l /home/httpd/html`;

For what it's worth, that would be much more efficient as this:

    opendir(DIR, "/home/httpd/html");
    @input=grep(!/^\./, readdir(DIR));
    closedir(DIR);

(Of course, that only generates a list of files, not the full "ls -l"
style listing, but that could easily be done with a stat() &
printf().)

Steve
-- 
steve@silug.org           | Linux Users of Central Illinois
(217)698-1694             | Meetings the 4th Tuesday of every month
Steven Pritchard          | http://www.luci.org/ for more info

--
To unsubscribe, send email to majordomo@silug.org with
"unsubscribe silug-discuss" in the body.