Path: utzoo!attcan!uunet!munnari!otc!metro!basser!nswitgould!hades!greyham From: greyham@hades.OZ (Greyham Stoney) Newsgroups: comp.os.minix Subject: fopen: "r" |/& "rb"? (was Re: utility to find strings in a file) Message-ID: <128@hades.OZ> Date: 13 Feb 89 21:42:23 GMT References: <659@mks.UUCP> Organization: Ausonics Pty Ltd, Sydney, Australia Lines: 24 in article <659@mks.UUCP>, wheels@mks.UUCP (Gerry Wheeler) says: > > I've also compiled this on U**x and MS-DOS. The only change required > for DOS was that the fopen() had to have binary mode added, so it looked > like this: > > fopen(argv[arg], "rb") > > This prevents DOS from returning EOF when it reads a ^Z character. Can someone correct me if I'm wrong, but the same code (namely "rb") should work for both shouldn't it?. In the MesSDOS case, it will see the "b" and hence open the file in binary mode; in the Unix/Minix case it only looks at the first character of the string anyway, so it sees the "r" and opens the file as you would expect. So, can't everyone use "rb" when they know it's a "binary" file {to make it easier for those who have to cope with MSDOS, but mightn't spot the problem}. Right? Wrong? Comments? Greyham -- # Greyham Stoney: (disclaimer not necessary: I'm obviously irresponsible) # greyham@hades.nucleus.oz - Ausonics. +61 2 428-6476 (my_phone@work) # replys WILL bounce; try: greyham@utscsd.oz - Uni of Technology, Sydney. # WARNING: Reply mail is VERY broken at present. Any replys to utscsd.oz pls