C
Craig
Hello friends at comp.lang.c,
I'm trying to combine 2 strings with a newline character at the end to write
to a file. When I view the file, the messages run together and some of the
str string is cut-off. A portion of the code is below. Any help would be
appreciated.
#define MAX_SIZE 256
char str[MAX_SIZE];
char lev[] = "INFO: ";
va_list ap;
va_start(ap, fmt);
vsprintf(str, fmt, ap);
va_end(ap);
strcat(lev, str);
write(fd, lev, strlen(fmt));
I'm trying to combine 2 strings with a newline character at the end to write
to a file. When I view the file, the messages run together and some of the
str string is cut-off. A portion of the code is below. Any help would be
appreciated.
#define MAX_SIZE 256
char str[MAX_SIZE];
char lev[] = "INFO: ";
va_list ap;
va_start(ap, fmt);
vsprintf(str, fmt, ap);
va_end(ap);
strcat(lev, str);
write(fd, lev, strlen(fmt));