:: Re: [DNG] Studying C as told. (For …
Góra strony
Delete this message
Reply to this message
Autor: Edward Bartolo
Data:  
Dla: dng
Temat: Re: [DNG] Studying C as told. (For help)
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