October 16, 2007

passing variables to subroutines in C

I always forget how to do it!

//declare variable globally
int TINF;

//in the subroutine use a * for a pointer, and then continue throughout
void epi_stats(int *TINF) {
*TINF = something;
}

//in the main program call the subroutine and assign the value using &
int main(int argc, char** argv) {
epi_stats(&TINF);
}


- No comments Not publicly viewable


Add a comment

You are not allowed to comment on this entry as it has restricted commenting permissions.

October 2007

Mo Tu We Th Fr Sa Su
Sep |  Today  |
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31            

Search this blog

Things_I_have_learnt_today

Most recent comments

  • que bonito color rosa tenes vos en tu site =) by carlos on this entry

Blog archive

Loading…
Not signed in
Sign in

Powered by BlogBuilder
© MMXIX