S
sathya
I have come across the following code which treys to implement the
strcat function. It may
be wrong or correct, but it is using integer zero instead of
appending the C string terminator '\0'.
#include <stdarg.h>
char *xstrcat(char *des, char *src, ...)
{
char *destination = des;
va_list v;
va_start(v, src);
while (src != 0)
{
while (*src != 0)
*des++ = *src++;
src = va_arg(v, char *);
}
*des = 0;
va_end(v);
return destination;
}
Is the above code is UB? Please explain.
--
"Combination is the heart of chess"
A.Alekhine
Mail to:
sathyashrayan AT gmail DOT com
(AT = @ and DOT = .)
strcat function. It may
be wrong or correct, but it is using integer zero instead of
appending the C string terminator '\0'.
#include <stdarg.h>
char *xstrcat(char *des, char *src, ...)
{
char *destination = des;
va_list v;
va_start(v, src);
while (src != 0)
{
while (*src != 0)
*des++ = *src++;
src = va_arg(v, char *);
}
*des = 0;
va_end(v);
return destination;
}
Is the above code is UB? Please explain.
--
"Combination is the heart of chess"
A.Alekhine
Mail to:
sathyashrayan AT gmail DOT com
(AT = @ and DOT = .)