Date: Thu, 22 Jan 1998 19:16:41 +0200 (IST) From: Eli Zaretskii To: Jamie Love cc: DJGPP mailing list Subject: Re: whats wromg with my file program? - HELP! In-Reply-To: <199801220709.UAA24275@fep1-orange.clear.net.nz> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Fri, 23 Jan 1998, Jamie Love wrote: > remdefs sprites.set > I get the djgpp.env file!!! instead of the correct sprites.set file. [snip] > if((length = fread(data, 1, length, inFile)) != -1) > { > printf("Error: unable to read %d bytes from %s", length, argv[1]); > return 0; > } > > printf("%s\n", data); You are assuming that `fread' appends an extra `\0' (null) character to the buffer after it reads the file. This is false. So when `printf' looks for the trailing `\0', which %s format requires, it happily runs beyond the end of data[] and prints what's left from the DJGPP.ENV processing by the startup code.