Compiling a C program on esus

  1. At the command line prompt (% on esus) type
    cc filename.c
    (If you have math.h included in your program, you need
    cc filename.c -lm
    which will link in the math library.)
    The cc invokes one of the C compilers. gcc will (should) also be available.
  2. You should get either some error messages or the prompt if the program compiled
  3. The compiled file is a.out (note: this is the default. Check your UNIX book - you should have one but if you don't, GET ONE - for compiling options which would allow you to have .out using names you choose.
  4. At the prompt, type a.out and your program will execute.

Getting a file to turn in using the script command

  1. The script command forces everthing that you type or have output to the screen into a file. Once the script session is over, the file can be printed and turned in as your hard copy.
  2. A script session looks like this: (indented part is in the script file and is not actually indented)
    % script myfilename
         % cat prog.c
         % a.out
         % whatever you need to input into the program
         % a.out (runs program again if needed)
         % exit
    % message concerning script session is printed and the file myfilename is now 
      in your directory and you are out of the script session
    
  3. Print out your script file to turn in as hard copy.