Glad you got it sorted. A few notes:
Note, those other warnings are significant too. I prefer to always be explicit with a function return type and parameter list. It's safest to never omit either, plus it helps the compiler do some error checking for you, making sure you are calling the functions correctly
main should be explicitly declared to return an integer. I also like to be explicit that main receives no parameters, though this is technically optional. Good job on actually returning a value though.
See here for more info: FAQ > main() / void main() / int main() / int main(void) / int main(int argc, char *argv[]) - Cprogramming.com.
Also, if you don't put a return type, C assumes the function returns int. But you don't want your half function to return anything, so you should explicitly declare it to have a void return type. Also, you should either put the half function above main, or put a prototype above main. C compilers read files top-down, and if it hasn't seen a declaration yet, it doesn't know what it is. Thus, it can't throw an error if you call half incorrectly. Even worse, this can theoretically cause the compiler to generate incorrect code in some circumstances, and may cause a program crash. That is unlikely, but it's still important to be correct. Never leave stuff up to chance, instead:
Code:
void half(int *i); // prototype -- looks just like the function itself, except with a ; at the end
...
int main(void) // takes no parameters, returns an int
{
...
half(&i); // now, if you called half incorrectly (wrong parameter count/type or return value type), the compiler would complain
...
return 0; // good -- we said main would return an int, and we meant it!
}
void half(int *i) // takes a pointer to int, returns nothing
{
*i = *i / 2;
// probably no printf here -- a function should do one thing (halve a value) and do it well
// also, no need for a return statement since it's a void function and there is nothing to return
// generally, you only use return; if you need to return early from a void function, like when there is an error
}