Parameters, Return Values & void in C
C passes arguments by value — always: the function receives private copies, so callers never change unless you hand over pointers. To modify caller data, pass addresses (void bump(int *p)) and dereference inside; to return multiple results, use several out-pointer parameters plus a status return.
An empty parameter list means unspecified arguments in old style — always write (void) for truly no parameters. main itself has two legal forms: int main(void) and int main(int argc, char *argv[]).
By value, always
void f(int x) works on a copy — caller data is untouched no matter what the body does.
Pointers for out-params
void bump(int *p) { (*p)++; } modifies the caller's variable through its address — C's only by-reference mechanism.
(void) means none
int f(void) takes zero arguments; bare int f() means unspecified — always spell (void) in new code.
Return status, output via pointers
Return 0/-1 success codes while results flow through pointer parameters — the standard C multi-result pattern.
#include <stdio.h> void bump(int *p) { (*p)++; } int main(void) { int n = 41; bump(&n); printf("%d\n", n); return 0;}Recommended resourcesAffiliate links · may earn us a commission
Recommended for learners
Practice what you learned
Re-implement each visualized algorithm in C yourself — building beats watching.