I am trying to concatenate arrays from a structure using strcat
. My code looks as follows:
int main(){
//Implementation of Search table Tree
struct searchTable
{
char first[10];
int first_id;
char second[10];
int second_id;
char third[10];
int third_id;
char fourth[10];
int fourth_id;
char fifth[10];
int fifth_id;
}input[5]= {
{"ABC", 101},
{"CAB",102},
{"ACB",103},
{"AAC",104},
{"CCB",105}
};
char join[100]={0};
strcat(join, input[0].first);
strcat(join, input[1].second);
strcat(join, input[2].third);
strcat(join, input[3].fourth);
strcat(join, input[4].fifth);
printf("%s", join);
Here the output instead of giving me
ABCCABACBAACCCB
gives me just
ABC
Could somebody tell me what I am doing wrong?