home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / c / 19348 < prev    next >
Encoding:
Internet Message Format  |  1993-01-07  |  1.9 KB

  1. Xref: sparky comp.lang.c:19348 comp.os.vms:20489
  2. Newsgroups: local.unix.help,comp.lang.c,comp.os.vms
  3. Path: sparky!uunet!haven.umd.edu!decuac!pa.dec.com!engage.pko.dec.com!e2big.mko.dec.com!dbased.nuo.dec.com!quark.enet.dec.com!lionel
  4. From: lionel@quark.enet.dec.com (Steve Lionel)
  5. Subject: Re: Using C to read Fortran Files
  6. Message-ID: <1993Jan7.030702.4174@dbased.nuo.dec.com>
  7. Sender: news@dbased.nuo.dec.com (USENET News System)
  8. Organization: Digital Equipment Corporation
  9. References: <C0Fyo3.70D@ccu.umanitoba.ca> <C0G1rw.81L@ccu.umanitoba.ca> <C0GHCC.Cwp@ccu.umanitoba.ca>
  10. Date: Thu, 7 Jan 1993 02:59:23 GMT
  11. Lines: 43
  12.  
  13.  
  14. In article <C0GHCC.Cwp@ccu.umanitoba.ca>, kaarts@ccu.umanitoba.ca 
  15. (Kenneth John Aarts) writes...
  16. >>I have a fortran program that does essentially
  17. >>    open(unit=1,"test",status='new')
  18. >>    write(1,10) 'cArt'
  19. >>10    format(a4)
  20. >>    end
  21. >>and then a C program that reads it:
  22. >>    int d1,d2,d3,d4,d5;
  23. >>    FILE *fp;
  24. >>    fp=fopen("test","r");
  25. >>    fscanf(fp,"%c%c%c%c%c",&d1,&d2,&d3,&d4,&d5);
  26. >>    printf("%d %d %d %d %d\n",d1,d2,d3,d4,d5);
  27. >>The output of the C program is:
  28. >>  10  65  114  116   13
  29. >>  LF  A    r   t    CR
  30. >>However, a fortran program reading the test program does see cArt.
  31.  
  32. It is the VAX C Run-Time Library which is doing this to you; it "interprets"
  33. the FORTRAN carriage control, turning the leading "c" into an LF, as that's
  34. what would happen if you printed the line on a terminal or printer.  WHY
  35. it does this I don't know, nor do I know how to stop it, but I thought
  36. that at the least you should know where the problem is located.  
  37.  
  38. All I can suggest is that, if possible, open the file from FORTRAN
  39. specifying CARRIAGECONTROL='LIST'.  I'll see what I can dig up about
  40. solutions from the VAX C end.
  41.  
  42. Steve Lionel                    lionel@quark.enet.dec.com
  43. SDT Languages Group
  44. Digital Equipment Corporation
  45. 110 Spit Brook Road
  46. Nashua, NH 03062
  47.