S
shane
Hi/
Been given this question, doesn't seem to make sense as it requires
function overloading:
Write a utility module that contains the following functions:
a) int getint(char *prompt)
Prompts the user then reads in an integer and returns the value
through the return value of the function (Copy the function from <foo>)
b) int getint(char *prompt, int max, int min, int *num)
as for the previous function, except it must check whether the
integer is in the given range (inclusive).
Obviously this requires function overloading, which is not supported in
C (C++ does apparently). And I get this output:
************************************
util.h:12: conflicting types for `getint'
util.h:11: previous declaration of `getint'
util.c:16: conflicting types for `getint'
util.h:12: previous declaration of `getint'
util.c:25: conflicting types for `getint'
util.c:16: previous declaration of `getint'
************************************
Am I missing something, or has my lecturer set an impossible question?
Can there be a VarArgs solution, only thing I can think of?
Been given this question, doesn't seem to make sense as it requires
function overloading:
Write a utility module that contains the following functions:
a) int getint(char *prompt)
Prompts the user then reads in an integer and returns the value
through the return value of the function (Copy the function from <foo>)
b) int getint(char *prompt, int max, int min, int *num)
as for the previous function, except it must check whether the
integer is in the given range (inclusive).
Obviously this requires function overloading, which is not supported in
C (C++ does apparently). And I get this output:
************************************
util.h:12: conflicting types for `getint'
util.h:11: previous declaration of `getint'
util.c:16: conflicting types for `getint'
util.h:12: previous declaration of `getint'
util.c:25: conflicting types for `getint'
util.c:16: previous declaration of `getint'
************************************
Am I missing something, or has my lecturer set an impossible question?
Can there be a VarArgs solution, only thing I can think of?