Here we do a closer analysis of some 'C' code
- Select a location on your system (or create such with a file manager).
- Open a terminal window; Navigate to that location.
- Open a text editor; Copy then paste the boxes below into your editor.
- (Arrange the terminal & text editor windows so both are seen side-by-side.)
- Save the first block of code below as 'goc'. Save the second as 'main.c'.
- In the terminal window, make shell script 'goc' executable: "chmod +x goc"
- Invoke the compile script with the line: "./goc pgm2"
- List the files present in the terminal. There should be 3: goc, main.c, pgm2.
- Invoke the newly-created program with './pgm2'
This code expands the prior 'pgm1' example by adding 2 styles of commenting, and adds the display of both numeric and character string variables in the 'printf()' function. The '#define' directive is introduced. The next article will examine a way to pass data to our executable at run-time. Using '#define' is an efficient way to allow rapid change of some numeric or character string, if that item is used frequently in various locations in multiple 'C' source files. For example, we might "#define MAX_WORDS 32", then later decide a larger value is better: "#define MAX_WORDS 64".