well, here are the pieces used. if you can find anything in the additional code thats relevant to solving my problem, then i apologize.
Code:
// -------------------------- mem.c ---------------------------
char *str_cat(char *s1, const char *s2)
{
char *tmp;
if ((tmp = realloc(s1, strlen(s1) + strlen(s2) + 1)) == NULL) {
perror("mem.c: str_cat(): realloc()");
return NULL;
}
strcat(tmp, s2);
s1 = tmp;
return s1;
}
char *str_new(const char *s)
{
char *new;
if ((new = malloc(strlen(s) + 1)) == NULL) {
perror("mem.c: str_new(): malloc()");
return NULL;
}
strcpy(new, s);
return new;
}
// ------------------------ comm.c -------------------------
char *out;
out = str_new("");
// ---- loop through another string here, char by char, and
// check for |R and other codes ----
case 'R': if (out) { str_cat(out, FRED); } else { out = str_new(FRED); } break;
there you have it... i only included case R because its the first and only case that applies to the string being processed.