Re: function pointers
- From: "Tomás Ó hÉilidhe" <toe@xxxxxxxxxxx>
- Date: Sun, 06 Jan 2008 19:46:12 GMT
Michal Nazarewicz <mina86@xxxxxxx> wrote in comp.lang.c:
Forgot about "()" and to be precise you should check if user_input is
>= 0 and <= 4.
The only redudant checks I use in my programs are asserts. If the input to a function should be between 0 through 4, then I'll document it and say that the behaviour is undefined if the input's out of range. Of course though, I'll still make liberal use of assert.
/* MyFunc
input : Number between 0 through 4
Behaviour is undefined if out of range
*/
void Func(unsigned const i)
{
assert(i < 5);
int arr[5];
arr[i] = 6;
}
--
Tomás Ó hÉilidhe
.
- Follow-Ups:
- Re: function pointers
- From: Michal Nazarewicz
- Re: function pointers
- From: Ark Khasin
- Re: function pointers
- References:
- function pointers
- From: hifrnds007
- Re: function pointers
- From: Tomás Ó hÉilidhe
- Re: function pointers
- From: Michal Nazarewicz
- function pointers
- Prev by Date: Re: Lazy evaluation question
- Next by Date: Re: min/max in stdlib.h?!
- Previous by thread: Re: function pointers
- Next by thread: Re: function pointers
- Index(es):