Subj : Re: malloc() To : borland.public.cpp.borlandcpp From : Sebastian Ledesma Date : Thu Jun 24 2004 05:54 pm Wayne: According to BC help: "When the operand is of type char (signed or unsigned), sizeof gives the result 1. When the operand is a non-parameter of array type, the result is the total number of bytes in the array (in other words, an array name is not converted to a pointer type). The number of elements in an array equals sizeof array/ sizeof array[0] ." but probably it refers to 'fixed size' array (eg: char name[20];) and not to dinamically created ones (char *name): too bad. Saludos Sebastian. PS: thanks for the fix. "Wayne A. King" escribió en el mensaje news:40db23c1.18290079@newsgroups.borland.com... > On Wed, 23 Jun 2004 13:03:35 -0300, "Sebastian Ledesma" > wrote: > > >Can you try something like this? > > I hope not. ;-) > > > char *p=realloc ( strlen( szInput ) + 1 ); > > Look at the prototype for realloc. It needs two arguments. > e.g. - char *p=realloc (txtBuf, strlen( szInput ) + 1 ); > > > n=sizeof(txtBuf )-1; //assuming 1 char wide :-) > > Nope. The expression sizeof(txtBuf) will give the size of the > txtBuf pointer variable itself, not the size of the allocation to > which it points. You can't get the allocated size using the > sizeof operator. (Which is usually evaluated at compile time > not at run time.) > > > -- > Wayne A. King > (waking@idirect.com, Wayne_A_King@compuserve.com) .