Hi,

Now I have several exercises from "The C programming language"
(Kernighan & Ritchie). Some question look rather challenging...

I learnt arrays are always passed by reference to function calls. So,
I wrote the following program to make use of this so that a variable
in main() is modified in a function call.

Is this technique used?

The program:
--------------------------
#include <stdio.h>

void times2(int i[]) {
  i[0] = 33;
}

int main () {
  int a = 15;
  printf("before function a = %d\n", a);

  times2(&a);
  printf("after function a = %d\n", a);

  return  0;
}
-----------------------

Edward
_______________________________________________
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng

Reply via email to