[ILUG] C string concat question ??
plop at redbrick.dcu.ie
Fri May 4 10:35:40 IST 2001
In reply to Dave Neary's flatulent wordings,
> Dave Neary wrote:
> > strcat((msg=strdup(strvar1),
> > (msg=realloc(msg,strlen(msg)+strlen(strvar2)+1))==NULL?
> > bad_stuff():msg),strvar2);
> works :) I was only confusing myself with the whole "order of
> evaluation" red herring, since the first arg doesn't go near the second
> arg. But anyone who ever used this should be shot :)
If order of evaluation was right to left however then you will be realloccing
an unallocated msg, strlen() msg which could lead to a seg fault if msg
doesn't point somewhere valid and generaly make things quite sucky
More information about the ILUG