C
cpphero
I'm looking at something a colleague has written and the function
looks like this:
void func(char buffer[ 80 ])
{
...
}
where the function will fill in the passed in buffer with some
meaningful data. Something about it doesn't seem quite right; I've
seen plenty of functions take a char* or char[] as an arg and assume
it is a null terminated string, or have a size param passed along, but
I've never encountered a char array of fixed length as an argument.
It compiles and seems to work, are there any pitfalls or reasons why
this shouldn't be done? Or am I just being paranoid?
looks like this:
void func(char buffer[ 80 ])
{
...
}
where the function will fill in the passed in buffer with some
meaningful data. Something about it doesn't seem quite right; I've
seen plenty of functions take a char* or char[] as an arg and assume
it is a null terminated string, or have a size param passed along, but
I've never encountered a char array of fixed length as an argument.
It compiles and seems to work, are there any pitfalls or reasons why
this shouldn't be done? Or am I just being paranoid?