View Single Post
Old 04-14-2004, 09:38 PM   #1 (permalink)
Engineer
Registered User
 
Join Date: Feb 2003
Location: cold
Posts: 5
Engineer is on a distinguished road
combining arrays

Hey everyone, I've tried searching but was unable to come up with a solution that would work for me. I have 3 arrays

Code:
char string1[] = {"My name is "};
char string2[] = {"Fred."};
char string3[50];
And I need to add string1 to string3, then add string 2 to string 3 (everything that was just added from string 1), Using a for or while loop.

Here is what I have so far, given to us by our prof:
Code:
for(int index = '0'; string1[index] != 0; ++index)
    string3[index] = string1[index];
for()
As I stated before we have to concatenate the 2 strings (3 with 2 appended) and it has to be generic so that it would work for any text that could fit in those strings, so that it reads "My name is Fred" as if it were all in one array.

TIA
Engineer is offline   Reply With Quote