Re: [PATCH] fread.3: Add example

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

 



On Thu, Jun 18, 2020 at 02:47:54PM +0000, Walter Harms wrote:
> 
> ________________________________________
> Von: Arkadiusz Drabczyk [arkadiusz@xxxxxxxxxxxx]
> Gesendet: Donnerstag, 18. Juni 2020 15:36
> 
> >>
> >> +    ret = fread(buffer, 1, 1, fp);
> >> +    if (ret != 1) {
> >> +        fprintf(stderr, "fread() failed: %zu\en", ret);
> >> +        exit(EXIT_FAILURE);
> >> +    }
> >> +
> >> please drop a line what case you want to explain here, looks like the same as above.
> 
> >As said a few lines above, this retrieves ELF class. I wanted to show
> >that file pointer moves automatically after fread() finishes.
> 
> ok i get the point(s).
> 1. you show you can read an "item" a bunch of bytes
> 
> the second read() should demonstrate that consecutive reads return
>  consecutive blocks of data (here the magic and class id of an ELF).

Exactly.

> perhaps you can support what want to show with a
> printf("pos=%ld\n",ftell(fp));
> before and after read.

Let's what Michael says. If he thinks this suggestion and the entire
example in the first place is a good idea I will add it.

-- 
Arkadiusz Drabczyk <arkadiusz@xxxxxxxxxxxx>



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux