-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctionPrototypes.c
More file actions
23 lines (18 loc) · 811 Bytes
/
FunctionPrototypes.c
File metadata and controls
23 lines (18 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdio.h>
void hello(char name[], int age); // function prototype
int main()
{
// function prototype = a function declaration without a body, before main()
// Many C compilers do not check for parameter matching, missing arguments will result in unexpected behavior
// Ensures that calls to a function are made with the correct arguments by flagging an error if arguments are missing
char name[] = "He";
int age = 21;
hello(name, age); // We might just write one argument into "()" instead of two: hello(name);
// But we got a function prototype, so it will be called with a warning to remind us of missing one argument
return 0;
}
void hello(char name[], int age)
{
printf("\nHello %s", name);
printf("\nYou are %d years old", age);
}