home *** CD-ROM | disk | FTP | other *** search
- /* TEST APPENDING TEXT TO A FILE TERMINATED WITH CTRL-Z */
- /* WORKS CORRECTLY UNDER VERSION 4 BUT FAILS UNDER VERSION 5 */
- #include <assert.h>
- #include <io.h>
- #include <memory.h>
- #include <process.h>
- #include <stdio.h>
- main()
- {
- static char old[] = { 'x', 'y' }, new[sizeof(old)];
- FILE *fp; static char nam[] = "XXXXXX";
- mktemp( nam );
- fp = fopen( nam, "wb" );
- fwrite( old, 1, 1, fp );
- fputc( '\x1A', fp ); /* old-style end-of-file */
- fclose( fp );
- fp = fopen( nam, "at" );
- fwrite( old+1, sizeof(old)-1, 1, fp );
- fclose( fp );
- fp = fopen( nam, "rt" );
- fread( new, sizeof(new), 1, fp );
- fclose( fp );
- assert( ! memcmp( old, new, sizeof( old ) ) );
- return remove( nam );
- }
-