Originally Posted by
Suhasa010
try declaring dest[200][13] globally or make it 'static'
Why?
OP -- I ran your code with:
Code:
char dest[200][13] = {"Sean", "Connery", "Micheal", "King", "James", "Wood"};
and got:
Code:
SeanConnery Connery MichealKing King JamesWood Wood
So not quite the same as you but close enough.
It looks like you're misunderstood what strcat() does. strcat(str1, str2) concatenates a copy of str2 onto the end of str1. It doesn't change str2 in any way. So assuming "MyStrCat" really is the same as strcat:
Code:
myStrCat(dest[i],dest[i+1]);
If dest[i] contains "Sean" and dest[i+1] contains "Connery", then after the strcat, dest[i] will contain "SeanConnery" and dest[i+1] will still contain "Connery". So you need to either have i += 2 as your loop increment in display(), or you need to reorganise your array to exclude the single names. If that's what you want then you'll need to copy the full names down so they're in consecutive elements, and probably zero out the rest of the elements. I'm not sure what you're trying to do though, as you still have a 200 (well, 208, typo?) loop terminator in display.