This is probably a really stupid question, but
I have an array of structs outside of int main
typedef struct{
char c;
int k;
}factor_t;
and I declared
factor_t *factors = malloc(INIT*sizeof(*factors));
where INIT
is 10
After running my function, I have an array of structs each which holds a char, c
, and integer, k
- e.g., factors[5].c
could hold "b"
or "d"
or "e"
and factors[5].k
could hold "3"
or "33"
or "333"
I need to somehow insert these into a string, but I can't seem to
strcat(destination,c or k);
they both give me pointer to integer errors, destination is a char*
How would I go about putting these into a string? I'm aiming to get a string that looks like
ck
ck
ck
that is, a pattern of "ck\n"
per struct, where c
= char and k
= integer
I use strcat(destination, "\n");
for the \n
and it works, but I can't do the same with c
and k