El 11/05/12 15:06, David C. Rankin escribió:
Guys,
I need a bit of help. I've tried to follow the example after wchar_t * wcscat that explains why using mempcpy is better than using strcat or wcscat, but I run into a segmentation fault attempting to use the suggested mempcpy replacement. The code in libc.html (Ver: 2.15) is shown below. I had to add the declaration for 's' to get past an undefined error (should have told me something right then).
char * concat (const char *str, ...) { va_list ap; size_t allocated = 100; char *result = (char *) malloc (allocated);
if (result != NULL) { char *newp; char *wp; const char *s; ^^^^^^^^^^^^^^^^^^
Yes, there is this oversight also in the example code...
result = concat( myS1, myS2, myS3 );
^^ here here, missing sentinel ... should say. concat( myS1, myS2, myS3, NULL ); -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org