Functions in C language

Thread Starter

circuit2000

Joined Jul 6, 2006
33
In one of my exams the following question was asked:
# List the 4 types of functions in C.
Here are they referring to the 4 library functions in C namely math.h,string.h,stdio.h & stdlib.h?
 

Papabravo

Joined Feb 24, 2006
13,972
I don't think so, since there are more different kinds of header files than there are cross ties on the railroad tracks. I think it relates to return value and arguments.
Rich (BB code):
void function_type_1(void)  //No arguments, No return value
void function_type_2(char)  //1 argument, No return value
char function_type_3(void)  //No arguments, Returns a char
char function_type_4(char)  //1 argument, Returns a char
Each of these function types would cause a compiler to generate different prologues and epilogs. If you don't know what those are, they are the instructions just before and just after a function call.
 

Dave

Joined Nov 17, 2003
6,970
In one of my exams the following question was asked:
# List the 4 types of functions in C.
Here are they referring to the 4 library functions in C namely math.h,string.h,stdio.h & stdlib.h?
To be fair that question is as ambiguous as can be. Depending on your interpretation, one could argue there are only two types of function in C: user defined functions (i.e. those that you write) and library functions. Then the type can be sub-divided further in the way Papabravo has specified above, and in a similar way you have in your OP.

If I received that question in an exam, I would probably be pretty miffed unless the lecturer had told me explicitly during the course that the 4 types of function in C are A).... B).... C).... and D)....

Dave
 
Top