Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #102729

Re: Using fread function

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: Using fread function
Date 2017-01-29 13:14 -0800
Organization None to speak of
Message-ID <lnefzlbmbd.fsf@kst-u.example.com> (permalink)
References <02c75a0c-84d7-4669-8bde-472730c7f8d3@googlegroups.com>

Show all headers | View raw


janus <emekamicro@gmail.com> writes:
> I just noticed that swapping the positions of the inner parameters
> does not have any material effect on result. That led me to think that
> "fread" function just multiple the two parameters.
>
> size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
>
> size_t fread(void *ptr,  size_t nmemb, size_t size, FILE *stream);
>
> Is my position correct?

I wrote about this here:

http://stackoverflow.com/a/8589688/827263

Quick summary: fread() returns the number of elements it was able
to read, and the ordering of the 2nd and 3rd arguments lets you
define what an element is.  Read a single data element if a partial
read is no better than not reading anything at all. Read in smaller
chunks if partial reads are useful.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Using fread function janus <emekamicro@gmail.com> - 2017-01-29 10:07 -0800
  Re: Using fread function "James R. Kuyper" <jameskuyper@verizon.net> - 2017-01-29 14:31 -0500
    Re: Using fread function supercat@casperkitty.com - 2017-01-30 08:03 -0800
    Re: Using fread function Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-01 13:59 -0800
      Re: Using fread function jameskuyper@verizon.net - 2017-02-05 11:40 -0800
        Re: Using fread function Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-08 22:04 -0800
          Re: Using fread function jameskuyper@verizon.net - 2017-02-09 05:39 -0800
            Re: Using fread function supercat@casperkitty.com - 2017-02-09 07:47 -0800
              Re: Using fread function Keith Thompson <kst-u@mib.org> - 2017-02-09 09:19 -0800
                Re: Using fread function supercat@casperkitty.com - 2017-02-09 09:55 -0800
                Re: Using fread function Keith Thompson <kst-u@mib.org> - 2017-02-09 12:10 -0800
                Re: Using fread function supercat@casperkitty.com - 2017-02-09 13:01 -0800
              Re: Using fread function Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-12 09:36 -0800
                Re: Using fread function supercat@casperkitty.com - 2017-02-12 10:52 -0800
                Re: Using fread function Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-19 21:19 -0800
                Re: Using fread function supercat@casperkitty.com - 2017-02-20 09:35 -0800
                Re: Using fread function Keith Thompson <kst-u@mib.org> - 2017-02-20 09:52 -0800
                Re: Using fread function supercat@casperkitty.com - 2017-02-20 11:15 -0800
                Re: Using fread function Keith Thompson <kst-u@mib.org> - 2017-02-20 11:45 -0800
                Re: Using fread function "James R. Kuyper" <jameskuyper@verizon.net> - 2017-02-20 15:38 -0500
                Re: Using fread function Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-23 12:12 -0800
                Re: Using fread function jameskuyper@verizon.net - 2017-02-24 10:37 -0800
                Re: Using fread function Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-23 05:04 -0800
                Re: Using fread function supercat@casperkitty.com - 2017-02-23 07:58 -0800
                Re: Using fread function Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-25 11:48 -0800
                Re: Using fread function jameskuyper@verizon.net - 2017-02-25 13:44 -0800
                Re: Using fread function Tim Rentsch <txr@alumni.caltech.edu> - 2017-04-17 13:12 -0700
                Re: Using fread function supercat@casperkitty.com - 2017-04-17 13:50 -0700
            Re: Using fread function Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-12 09:31 -0800
  Re: Using fread function Keith Thompson <kst-u@mib.org> - 2017-01-29 13:14 -0800
  Re: Using fread function Malcolm McLean <malcolm.mclean5@btinternet.com> - 2017-01-30 08:18 -0800
    Re: Using fread function supercat@casperkitty.com - 2017-01-30 08:44 -0800
    Re: Using fread function Keith Thompson <kst-u@mib.org> - 2017-01-30 11:58 -0800
      Re: Using fread function Malcolm McLean <malcolm.mclean5@btinternet.com> - 2017-01-30 13:05 -0800
        Re: Using fread function supercat@casperkitty.com - 2017-01-30 13:39 -0800
        Re: Using fread function Keith Thompson <kst-u@mib.org> - 2017-01-30 13:57 -0800

csiph-web