AW: [PATCH] fread.3: Add example

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

 



________________________________________
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).

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

hope that helps,
re,
 wh

--
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