[PLUG] source code of echo command...

Vaibhav Kulkarni netvaibhav at gmail.com
Tue Jul 31 03:14:56 PDT 2007


On 7/31/07, Sameer Oak <sameer.oak at gmail.com> wrote:
> Besides this, Vaibhav, the code snippet you gave had thousands of flaws. I
> don't really start enumerating them now. A hint for you, however, that code
> doesn't say anything about STDOUT_FILENO and STDERR_FILENO (stdout and
> stderr what commonly known as, one can find them in unistd.h). I
> particularly wanted to see the way these file descriptors were handled by

What has the echo command to do with STDOUT_FILENO and STDERR_FILENO?
You mean I should have used
write(STDOUT_FILENO, argv[i], strlen(argv[i]))
instead of
printf("%s", argv[i])
? That's pretty silly.

And no, STDOUT_FILENO and STDERR_FILENO, and stdout and stderr are not
the same. The former are integers (file descriptors, with value 1 and
2 resp.) while the later are pointers to FILE structure. Former used
by read/write family of functions, while the later used by
fread/fwrite family of functions.

I don't quite understand what you mean by 'handling' file descriptors.

> echo.c

I assume this is the file name you gave to my code snippet. If not,
please point to the source you are talking about.

-- 
Vaibhav

P.S. Thousands of flaws in 4 lines of code? I should get some award
for writing code with highest flaws/lines ratio.



More information about the plug-mail mailing list