:: Re: [DNG] Studying C as told. (For …
トップ ページ
このメッセージを削除
このメッセージに返信
著者: Edward Bartolo
日付:  
To: dng
題目: 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