On Sun, 27 Nov 2011, nierveze wrote:
thanks for your help,srecord will be ok,I think,but I
also have saved the
program in c.
I used to give that and the inverse as early exercises in file I/O
in my [beginning] Assembly class, and as simple examples in my Data
Structures and Algorithms class for unions, shifts, ANDs, file I/O
Some students had difficulty grasping the concept of one input, two
outputs (and vice versa, where I showed it right before merging files)
Another difficulty that many students always had was processing data, such
as sorting or searching, WITHOUT reading it all into memory. "Bigger than
64K? ADD RAM!; Bigger than 1M? ADD RAM!", so I made them write a sort
program with NO file size limits, and one whose only size limits were the
file size limits of the OS (MS-DOS FAT12 permitted files from -2147483648
to 2147483647 bytes), which was even harder.
Amongst the obvious possibilities for splitting the file are:
read byte
write byte to file1
read byte
write byte to file2
read word
write byte to file1
write byte to file2
WATCH OUT FOR: some compilers want to [by default] fopen() files in "TEXT"
mode, and stop when they hit char26, or other none end-of file "EOF"
characters. Most such compilers have switches to over-ride without
necessarily changing from fopen() to open()
Surely you can reduce it to much less than 12 lines in "high level"
languages!
--
Grumpy Ol' Fred cisin at
xenosoft.com