Re: splitting a file
- From: Michael Mair <Michael.Mair@xxxxxxxxxxxxxxx>
- Date: Sat, 20 Aug 2005 11:05:03 +0200
Afifov wrote:
How can I split a file into several files each with a fixed size? I recall that on linux there is a command that has a counter for file size
in bytes but cant seem to remember.
Help is appreciated.
As this is comp.lang.c and not some Linux newsgroup, I suggest you get the name of the file to be split, the maximum size S of the parts, fopen() the file in binary mode and then 1) Try to fread() up to S bytes with return of R read bytes 2) Try to open the file for the next part (do you want to overwrite or die on error?) 3) fwrite() R bytes to the current output file, close it. 4) if R<S, terminate. Else continue at 1.
fclose() your source file. Done.
<OT>Have you tried 'man split'?</OT
Cheers Michael -- E-Mail: Mine is an /at/ gmx /dot/ de address. .
- References:
- splitting a file
- From: Afifov
- splitting a file
- Prev by Date: Re: Linking Libraries
- Next by Date: Re: splitting a file
- Previous by thread: splitting a file
- Next by thread: Re: splitting a file
- Index(es):
Relevant Pages
|