Path: utzoo!censor!geac!yunexus!xrtll!silver From: silver@xrtll.uucp (Hi Ho Silver) Newsgroups: comp.sys.ibm.pc Subject: Re: File concatenation using Microsoft C under MS-DOS? Message-ID: <1990Jun10.151036.25368@xrtll.uucp> Date: 10 Jun 90 15:10:36 GMT References: <4891@druco.ATT.COM> Reply-To: silver@.UUCP (PUT YOUR NAME HERE) Organization: Not around here, pal! Lines: 37 In article <4891@druco.ATT.COM> gibbons@druco.ATT.COM (GibbonsT) writes: $ What's the quickest way to concatenate one large file (~100K) to $ another using Microsoft C under MS_DOS? Write now I'm just opening $ the two files and reading from one and append to the other, but it $ is rather slow. The DOS "copy" command can do this much more $ quickly using "copy A + B" but I can't figure out how to run $ "copy" from a C program. I've tried calling "copy" with a $ spawnl() command but that didn't work so i made a batch file $ that called copy and then tried to spawnl() the batch file, $ but that didn't work. So, any suggestions? Any I overlooking $ something extremely obvious? As far as trying to invoke a child process, you can't use spawn for what you're trying: - you can't spawn copy since it's ain internal command and spawn will only run .com and .exe commands - you can't spawn a batch file since it requires command.com The ways around these are to use tye system() call, which passed your argument to a copy of the command processor (basically, it comes up with the equivalent of a spawn to "command /c your-commands-here"). I assume your C solution involved simply reading the files one character at a time. This is not a good way to do it, since there's a certain amount of overhead in each read you do and it adds up like crazy. The way to do it is to find the commands in your implementation of C that allow you to read and write large blocks at a time. If memory serves, the Turbo C calls are blockread() and blockwrite(), which will read and write as much (up to 64K) of a file as you want them to. This speeds things up tremendously. I'm sure MSC has equivalent calls. -- /Nikebo \ Nikebo says "Nikebo knows how to post. Just do it."\silver@xrtll/ /---------\_____________________________________________________\----------/ /yunexus!xrtll!silver (L, not 1)\ Hi Ho Silver \ just silver for short / /Silver: Ever Searching for SNTF \ Life sucks. \ someone buy me a BEER! /