> $ cat t.c
> #include <stdio.h>
>
> int main(int argc, char **argv)
> {
> char buf[8192];
> int i;
>
> memset(buf, 0, sizeof(buf));
> for (i=0; i<sizeof(buf); i++)
> write(1, buf, 1);
> return (0);
> }
So this program is writing the first byte of buf, 8192 times. Let's
call this program an apple.
Did you mean:
write(1, buf+i, 1) ?
And...
> [mrsam@ny mrsam]$ cat t.c
> #include <stdio.h>
>
> char buf[8192];
>
> int main(int argc, char **argv)
> {
> int i;
> char *p;
>
> memset(buf, 0, sizeof(buf));
>
> p=buf;
> for (i=0; i<sizeof(buf); i++)
> *p++=0;
>
> write(1, sizeof(buf), 1);
> return (0);
> }
(Did you try running this program - the second param
to write should be an address, not a size_t)?
This program is filling buf with binary zeroes twice, then
writing one random byte once. Let's call this program
an orange.
What exactly are you trying to compare here?
Regards.