I appreciate any help; I'm currently getting a problem with trying to concatenate a single char from a structure to an existing string. Basically, the problem is here:
strcat( res, morse_c[j].letter )
morse_c[j].letter should return an alphabet 'a' or 'b', etc...
I'm trying to concatenate that to a char *res and it returns the error:
'strcat' : cannot convert parameter 2 from 'char' to 'const char *'
I"ve tried casting it --> (const char*) morse_c[j].letter AND forcing the alphabets to const char type by using double quotes "a", "b", etc...
None worked. I've also tried setting res[i] = morse_c[j].letter and it doesn't work. When I return res, it only returns the first value res[0] and not the whole res string
Thank you!
PS: I'm thinking of changing my structure of letter to const char* but that will be a mess.
Code snipets:
char *res = (char *)calloc(200, sizeof(char));
Structure data:
typedef struct {
char letter;
char sequence[100];
} morse_t;
morse_t* codeGen(){
morse_t *res = (morse_t*) calloc(TABLE_SZ, sizeof(morse_t));
res[0] = make_morse( 'a', ".-" );
res[1] = make_morse( 'b', "-...");
res[2] = make_morse( 'c', "-.-.");
res[3] = make_morse( 'd', "-..");
... until the table is populated