home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!sun-barr!olivea!spool.mu.edu!umn.edu!noc.msc.net!uc.msc.edu!shamash!ems!ems.cdc.com!mstemper
- From: mstemper@ems.cdc.com (Michael Stemper)
- Newsgroups: comp.lang.fortran
- Subject: Re: Switching from Fortran to C
- Message-ID: <22578@nntp_server.ems.cdc.com>
- Date: 11 Sep 92 17:25:34 GMT
- References: <92253.131825BOYDJ@QUCDN.QueensU.CA>
- Sender: sys@ems.ems.cdc.com
- Reply-To: mstemper@ems.cdc.com
- Organization: Empros Systems International, a division of Ceridian
- Lines: 44
- Nntp-Posting-Host: kirk.ems.cdc.com
-
- In article <92253.131825BOYDJ@QUCDN.QueensU.CA>, BOYDJ@QUCDN.QueensU.CA (Jeff Boyd) writes:
- |>
- |> C and Fortran programs can look very much alike if you want them to.
-
- And if you really want to drive a hard-core C programmer crazy, show them
- that their C compiler will accept this file:
- -----included file----
- # include "me.h"
-
- PROGRAM
-
- INTEGER FIRST, SECOND
- C
- FIRST = 1234
- C
- SECOND = 73
- C
- WRITE( OUTPUT, FORMAT, FIRST, SECOND, FIRST MOD SECOND )
- C
- STOP
- -----end of included file------
- This will actually be accepted by a C compiler and run properly.
- A Fortran compiler would reject it, due to the hosed WRITE statement.
- The trick is in the file "me.h", which follows:
- -----included file----
- # include <stdio.h>
- # define PROGRAM int main() {
- # define STOP exit(0); }
- # define WRITE fprintf
- # define MOD %
- # define OUTPUT stdout
- # define INPUT stdin
- # define ERRLIST stderr
- # define INTEGER int
- # define C ;
- # define I2 %d
- # define FORMAT " %d mod %d is %d \n"
- -----end of included file------
-
- --
- #include <Standard_Disclaimer.h>
- Michael F. Stemper
- Power Systems Consultant
- mstemper@ems.cdc.com
-