Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!usc!wuarchive!zaphod.mps.ohio-state.edu!caen!news.cs.indiana.edu!ux1.cso.uiuc.edu!news.iastate.edu!niko From: niko@iastate.edu (Schuessler Nikolaus E) Newsgroups: comp.sys.mac.programmer Subject: Re: THINK C 4.0 bug Message-ID: <1991Mar4.021143.28647@news.iastate.edu> Date: 4 Mar 91 02:11:43 GMT Sender: news@news.iastate.edu (USENET News System) Distribution: na Organization: Iowa State University, Ames, IA Lines: 33 >during the decoder portion, i use > putc(o, stdout); >to output a calculated integer (lower byte only). > >but when o is equal to 10 (checked it while in debugger), >it outputs 13. (checked from a hex dump of output file). >the stdout is redirected with a ccommand. > >any ideas? Yep. Unix uses a 0x0a (10) as an end of line and the mack uses a 0x0d to remain compatible, it does you a "favor" and automatically translates it for you. This is great if you are just writing/reading textfiles but it really sucks when you are writing binary. (THis is one of the many problems when porting Unix code to THINK) To solve this problem, you can do one of two things: 1) Use FOpen, Fclose and make your own putC & buffering routines 2) open the file with "wb" (i.e. fp=fopen("file.out","wb")) the 'b' indicates binary writing do no translating on unix you can get away without the 'b' so most people don't put it in.... Hope that helps.... --