Let's jump right in.

 

Working in a terminal window requires knowledge of command-line commands, such as 'cd', 'ls',
'cp', 'rm', 'cat' and others. Here's a brief YouTube shell tutorial

 

  1. Select a location on your system (or create such with a file manager).
  2. Open a terminal window;  Navigate to that location.
  3. Open a text editor; Copy then paste the boxes below into your editor.
  4. (Arrange the terminal & text editor windows so both are seen side-by-side.)
  5. Save the first block of code below as 'goc'.  Save the second as 'main.c'.
  6. In the terminal window, make shell script 'goc' executable:  "chmod +x goc"
  7. Invoke the compile script with the line:   "./goc pgm1"
  8. List the files present in the terminal.  There should be 3:  goc, main.c, pgm1.
  9. Invoke the newly-created program with './pgm1'

 

#!/bin/bash
# invoke this script with desired name of executable
# 'C' source code is expected in file 'main.c'
# flag the compiler to provide more error and warning checks
pgmname=$1
gcc main.c -Wall -o $pgmname

 

(right-click to download) 

#include <stdio.h>

int main(void) {
printf("Hello, world!\n");
return(0);
}  

 

Converting the source code for our 'C' program, to result in an executable program, can involve steps that repeat in a somewhat circular fashion.  Generally, the work flow takes this pattern: