Actions

EmSys

C - Pointers and function arguments

From EdWiki

Pointers and function arguments

  • Pointers can be passed and/or returned by functions.
  • If the arguments are passed by value to functions, It is not possible for the called function to alter a variable in the calling function.
  • Pointer arguments enable a function to access and change objects in the functions that called it.
  • Since pointers are variables themselves, they can be stored in arrays just as other variables can.
char*  lineptr[MAXLINES];

says that lineptr is an array of MAXLINES elements, each element of which is a pointer to a char.

that is, lineptr[i] is a character pointer, and *lineptr[i] is the character it points to, the first character of the ith pointer.