hans nieuwenhuizen wrote: Please note that this list is for help using gcc, not general programming questions. Nothing in your message is specific to gcc so you should really find a more general purpose programming list as this is off topic. > For byte by byte comparison of 2 files the linux function `cmp` works a great > many times faster than a written C-program which exits at first difference > found. The 'cmp' program has a number of checks such as "are both files the same inode" and "do the files have different lengths" that can cause it to exit immediately. 'cmp' also does buffered IO using an appropriate block size. If your implementation is reading one byte at a time it will be much slower. > But `cmp` returns a bool for 'equal or not equal' and writes the position of > the first byte found different to <stdout>, which I of course can redirect to > disk and reread from disk. > > But I do not want to spoil the time on xx00 GB of files and copy the number > directly ( via environment, fork or assembly ) into a C|C++ variable for > further processing and skip the diskwrite. You can use a pipe to receive the output, and there will be zero disk IO. > Can anybody tell me how to realize that or where to find the info? It is not > in Richard Stevens and I cannot find the source of `cmd` on my Suse 8.2 > system. The 'cmp' command is part of the package 'diffutils', so either install the source package or get the source tarball from the GNU site. Brian