Dealing with returning C strings

What is considered better practice when writing methods that return strings in C?

passing in a buffer and size:

void example_m_a(type_a a,char * buff,size_t buff_size)

or making and returning a string of proper size:

char * example_m_b(type_a a)

P.S. what do you think about returning the buffer ptr to allow assignment style and nested function calls i.e.

char * example_m_a(type_a a,char * buff,size_t buff_size)
{
...
return buff;
}
8
задан Roman A. Taycher 5 May 2011 в 05:40
поделиться