home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c:19348 comp.os.vms:20489
- Newsgroups: local.unix.help,comp.lang.c,comp.os.vms
- 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
- From: lionel@quark.enet.dec.com (Steve Lionel)
- Subject: Re: Using C to read Fortran Files
- Message-ID: <1993Jan7.030702.4174@dbased.nuo.dec.com>
- Sender: news@dbased.nuo.dec.com (USENET News System)
- Organization: Digital Equipment Corporation
- References: <C0Fyo3.70D@ccu.umanitoba.ca> <C0G1rw.81L@ccu.umanitoba.ca> <C0GHCC.Cwp@ccu.umanitoba.ca>
- Date: Thu, 7 Jan 1993 02:59:23 GMT
- Lines: 43
-
-
- In article <C0GHCC.Cwp@ccu.umanitoba.ca>, kaarts@ccu.umanitoba.ca
- (Kenneth John Aarts) writes...
- >
- >>I have a fortran program that does essentially
- >
- >> open(unit=1,"test",status='new')
- >> write(1,10) 'cArt'
- >>10 format(a4)
- >> end
- >
- >>and then a C program that reads it:
- >
- >> int d1,d2,d3,d4,d5;
- >> FILE *fp;
- >> fp=fopen("test","r");
- >> fscanf(fp,"%c%c%c%c%c",&d1,&d2,&d3,&d4,&d5);
- >> printf("%d %d %d %d %d\n",d1,d2,d3,d4,d5);
- >
- >>The output of the C program is:
- >
- >> 10 65 114 116 13
- >
- >> LF A r t CR
- >
- >>However, a fortran program reading the test program does see cArt.
- >
-
- It is the VAX C Run-Time Library which is doing this to you; it "interprets"
- the FORTRAN carriage control, turning the leading "c" into an LF, as that's
- what would happen if you printed the line on a terminal or printer. WHY
- it does this I don't know, nor do I know how to stop it, but I thought
- that at the least you should know where the problem is located.
-
- All I can suggest is that, if possible, open the file from FORTRAN
- specifying CARRIAGECONTROL='LIST'. I'll see what I can dig up about
- solutions from the VAX C end.
-
- Steve Lionel lionel@quark.enet.dec.com
- SDT Languages Group
- Digital Equipment Corporation
- 110 Spit Brook Road
- Nashua, NH 03062
-