home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / atari / st / tech / 6523 < prev    next >
Encoding:
Internet Message Format  |  1993-01-07  |  1.6 KB

  1. Path: sparky!uunet!mcsun!uknet!fulcrum!its!silver.its.bt.co.uk!jvt
  2. From: jvt@its.bt.co.uk (John Trickey)
  3. Newsgroups: comp.sys.atari.st.tech
  4. Subject: Re: Porting UNIX Code to the ST
  5. Message-ID: <1993Jan7.124324.27805@its.bt.co.uk>
  6. Date: 7 Jan 93 12:43:24 GMT
  7. References: <1993Jan5.214420.8268@sae.com>
  8. Sender: @its.bt.co.uk
  9. Organization: BT Group Computing Services, Birmingham, UK
  10. Lines: 27
  11.  
  12. In article <1993Jan5.214420.8268@sae.com> malay@sae.com writes:
  13. >
  14. >I have some code that generates a binary file - I compiled it with GCC 2.3.1
  15. >and ran it on the ST - it works fine, it generates a binary file; however, the
  16. >print statements seem to be outputting a CNTRL-M (^M) - I don't need these
  17. >extra characters what should I do to get rid of them???
  18.  
  19.  
  20. The problem you have encountered is that Unix treats all files alike while
  21. DOS, TOS etc do not. In Unix the open is fopen(filename,mode) where mode is
  22. a char * of "a","r","w","r+","w+","a+". In TOS these are for text files with
  23. CRLF being converted to LF on input and LF being converted to CRLF on output.
  24. Note CR is ^M.
  25. To switch this off you need to open the file in binary mode. These modes
  26. are "ab","rb","wb","rb+","wb+","ab+". The format "r+b" etc is also acceptable.
  27.  
  28. NOTE for developers:
  29. There is nothing stopping you using these binary formats in Unix. Any decent
  30. implementation will recognize them. They obviously will have no effect but
  31. its then easy to port to DOS-type environments.
  32.  
  33. John
  34. -- 
  35. John Trickey <jvt@its.bt.co.uk>
  36.        Voice: +44 21 524 8200     Fax: +44 21 553 6120
  37. (Home) <john@its.bt.co.uk> || <john@g4rev.ampr.org> || G4REV @ GB7FLG
  38.        +44 21 308 8892
  39.