Reputation: 131
I have two arrays of pointers, that is,
char *a[3]= {"man","dog","cat"};
char *b[3]= {"job","rain","sleep"};
I want to separate the three strings of both above into three different characters arrays and then I want to concatenate the string from *b[]
to the end of string from *a[]
.
How can I accomplish this? I don't want to print the separated strings.
Upvotes: 0
Views: 73
Reputation: 310910
If I have understood correctly you want the following
char s[3][10];
for ( size_t i = 0; i < 3; i++ )
{
strcpy( s[i], a[i] );
strcat( s[i], " " );
strcat( s[i], b[i] );
}
Upvotes: 1