home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / c / 19315 < prev    next >
Encoding:
Text File  |  1993-01-06  |  928 b   |  41 lines

  1. Newsgroups: local.unix.help,comp.lang.c
  2. Path: sparky!uunet!newsflash.concordia.ca!mizar.cc.umanitoba.ca!kaarts
  3. From: kaarts@ccu.umanitoba.ca (Kenneth John Aarts)
  4. Subject: Using C to read Fortran Files
  5. Message-ID: <C0Fyo3.70D@ccu.umanitoba.ca>
  6. Sender: news@ccu.umanitoba.ca
  7. Nntp-Posting-Host: ccu.umanitoba.ca
  8. Organization: University of Manitoba, Winnipeg, Manitoba, Canada
  9. Date: Wed, 6 Jan 1993 16:48:02 GMT
  10. Lines: 29
  11.  
  12.  
  13. I have a fortran program that does essentially
  14.  
  15.     open(unit=1,"test",status='new')
  16.     write(1,10) 'cArt'
  17. 10    format(a4)
  18.     end
  19.  
  20. and then a C program that reads it:
  21.  
  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.  
  28. The output of the C program is:
  29.  
  30.   10  65  114  116   13
  31.  
  32.   LF  A    r   t    CR
  33.  
  34. However, a fortran program reading the test program does see cArt.
  35.  
  36. How do I get C to find the c in cArt?
  37.  
  38. Thanks,
  39.  
  40. Ken
  41.