Hi
I have a sequence that I want to put into a seperate function:
The variables I want to take into that function and back to the main function are declared globally.
declaring the function and the testing variable:
void sanction ();
int test[10];
my main function:
int main(int argc, char *argv[])
{
test[10] = 10;
printf ("in main: 10 = %d\n", test[10]);
sanction ();
printf ("in main after adding: 10 = %d\n", test[10]);
return (0);
}
the separate function:
void sanction( void )
{
printf ("in sanction: 10 = %d\n", test[10]);
test[10] = test[10] + 1;
}
output:
in main: 10 = 10
in sanction: 10 = 10
in main after adding: 10 = 11
So everything works like it should, but why?
I thought the void ment no variable-values are taken to the separate function and none are returned.
I just want to be sure that when I use this with the actual code, I'm not making any mistakes.
thx