"alberto" <> wrote in message
> tnx for info. Yes, the array of chars is a member of a struct and stored
> in a binery file. I think I should read each "register" of the file, and
> then try to determine the real lenght of the field "array of char" and
> after that call calloc or malloc function properly. Correct ?
> Tnx
> Alberto
That's right.
struct record
{
char *astring;
};
Will store a string of any length, if you allocate the "astring" member with
malloc().
It is very debatable whether there will be any benefit over a fixed buffer
size of 50 bytes. Normally malloc uses a few bytes for overhead, and then
you have the extra run-time and complication of calling the allocation
function and freeing it.
However if the strings were several kilobytes in length, this would be the
only realistic option.
--
Buy my book 12 Common Atheist Arguments (refuted)
$1.25 download or $7.20 paper, available
www.lulu.com/bgy1mm