home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / fortran / 3522 < prev    next >
Encoding:
Text File  |  1992-09-11  |  1.6 KB  |  58 lines

  1. Path: sparky!uunet!sun-barr!olivea!spool.mu.edu!umn.edu!noc.msc.net!uc.msc.edu!shamash!ems!ems.cdc.com!mstemper
  2. From: mstemper@ems.cdc.com (Michael Stemper)
  3. Newsgroups: comp.lang.fortran
  4. Subject: Re: Switching from Fortran to C
  5. Message-ID: <22578@nntp_server.ems.cdc.com>
  6. Date: 11 Sep 92 17:25:34 GMT
  7. References: <92253.131825BOYDJ@QUCDN.QueensU.CA>
  8. Sender: sys@ems.ems.cdc.com
  9. Reply-To: mstemper@ems.cdc.com
  10. Organization: Empros Systems International, a division of Ceridian
  11. Lines: 44
  12. Nntp-Posting-Host: kirk.ems.cdc.com
  13.  
  14. In article <92253.131825BOYDJ@QUCDN.QueensU.CA>, BOYDJ@QUCDN.QueensU.CA (Jeff Boyd) writes:
  15. |> 
  16. |> C and Fortran programs can look very much alike if you want them to.
  17.  
  18. And if you really want to drive a hard-core C programmer crazy, show them
  19. that their C compiler will accept this file:
  20. -----included file----
  21. # include "me.h"
  22.  
  23.       PROGRAM
  24.  
  25.       INTEGER   FIRST, SECOND
  26. C
  27.       FIRST  = 1234
  28. C
  29.       SECOND = 73
  30. C
  31.       WRITE( OUTPUT, FORMAT, FIRST, SECOND, FIRST MOD SECOND )
  32. C
  33.       STOP
  34. -----end of included file------
  35. This will actually be accepted by a C compiler and run properly.
  36. A Fortran compiler would reject it, due to the hosed WRITE statement.
  37. The trick is in the file "me.h", which follows:
  38. -----included file----
  39. # include <stdio.h>
  40. # define PROGRAM int main() {
  41. # define STOP    exit(0); }
  42. # define WRITE   fprintf
  43. # define MOD     %
  44. # define OUTPUT  stdout
  45. # define INPUT   stdin
  46. # define ERRLIST stderr
  47. # define INTEGER int
  48. # define C       ;
  49. # define I2      %d
  50. # define FORMAT  " %d mod %d is %d \n"
  51. -----end of included file------
  52.  
  53. -- 
  54. #include <Standard_Disclaimer.h>
  55. Michael F. Stemper
  56. Power Systems Consultant
  57. mstemper@ems.cdc.com
  58.