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


Groups > comp.lang.c > #8458

Re: skipping bytes

From John Gordon <gordon@panix.com>
Newsgroups comp.lang.c
Subject Re: skipping bytes
Date 2011-07-18 21:35 +0000
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <j028v2$8ne$1@reader1.panix.com> (permalink)
References <4e24a281$0$1929$bbae4d71@news.suddenlink.net>

Show all headers | View raw


In <4e24a281$0$1929$bbae4d71@news.suddenlink.net> "Bill Cunningham" <nospam@nspam.invalid> writes:

>     I want to take a 700MB file and skip evey 200MB, so I thought of this.

You mean you want to copy the 700MB file to another file, omitting
200MB chunks?

> long * space=malloc(sizeof(long)*500000);

There's no need to allocate that much space for a simple copy operation.
You can copy, say, 8K or 16K at a time without allocating a huge buffer.

> That would be good for code wouldn't it? Now how to tell where I am in the 
> file. I have two choices. ftell() and fseek() or use f*pos() functions. 
> Would anyone have any suggestions?

The f*pos() functions handle files which are too large for ftell/fseek,
and they also have special code to handle multibyte stream content.

If you don't care about those two concerns, then either functions will
work.

(By the way, I got this information by doing a Google search on the
phrase "what is the difference between ftell and fgetpos?")

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

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


Thread

skipping bytes "Bill Cunningham" <nospam@nspam.invalid> - 2011-07-19 05:15 -0400
  Re: skipping bytes John Gordon <gordon@panix.com> - 2011-07-18 21:35 +0000
    Re: skipping bytes "Bill Cunningham" <nospam@nspam.invalid> - 2011-07-19 05:43 -0400
      Re: skipping bytes blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-07-19 17:27 +0000
        Re: skipping bytes Chad <cdalten@gmail.com> - 2011-07-19 12:09 -0700
          Re: skipping bytes blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-07-19 21:34 +0000
        Re: skipping bytes "Bill Cunningham" <nospam@nspam.invalid> - 2011-07-20 03:17 -0400
          Re: skipping bytes blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-07-19 21:35 +0000
            Re: skipping bytes "Bill Cunningham" <nospam@nspam.invalid> - 2011-07-20 07:01 -0400
            Re: skipping bytes "Bill Cunningham" <nospam@nspam.invalid> - 2011-07-22 11:25 -0400
  Re: skipping bytes Ian Collins <ian-news@hotmail.com> - 2011-07-19 09:42 +1200

csiph-web