HomeModules → Module 2.2 (Args) →Introduction
I ntroduce
C onnect
A pply
R eflect
E xtend

Introduce - Arguments

In this module we will cover the topic of arguments, which allow us to pass information into a program for use and manipulation by that program.

Up until now, the programs we’ve been working on have either been ‘self-contained’ (They’ve gotten no information from the outside world), or have extracted data from a file via the read statement.

This module gives us an introduction on how to pass data to a program at the command

 

line, as well as providing a tutorial on the concept of pointers, double pointers, and allocating memory to variables (These concepts are the building blocks that will allow us to take information into a program and process that information).

Passing command line arguments turns out to provide 2 important advantages over other forms:

  1. It's easier to program and run than incorporating read statements and creating files with data.
  2. In the (very near) future, we will fork processes (Don't worry if you don't know what this means yet; we'll cover the concept of creating, or forking, processes soon enough) to perform tasks in parallel; when we fork the new process, we do so as a command, and any data we pass to the forked processes will be passed as command line arguments.

We’ll provide programs with information (Arguments) in a very formal way, so that the program can use that information and perform some useful tasks with it.

Like everything associated with the C programming language, there is a very formal syntax associated with passing arguments into a program.

The following section (Connect) will cover the specifics of that syntax and give us a chance to see some examples of the benefits of argument-passing to programs. The final sections will provide us with the opportunity to testing our understanding of the argument passing syntax (Apply), as well as testing our knowledge via questions that will be generated from example programs and the arguments passed to them.

Finally, we’ll think about benefits and limitations of this method of data-passing (Reflect), and think about other ways of providing information to programs (Extend).

Click here to move on to the next section (Connect).