string concatenation using pointer
C / C++ / MFC
21
Posts
7
Posters
0
Views
1
Watching
-
That's almost the solution... :rolleyes:, try:
char *a,*b;
char *temp, *dest;
dest=new char[5];
temp = dest;
a="aa";
b="bb";
while(*a!='\0')
{
*temp++ =*a++ ;
}
while(*b!='\0')
{
*temp++= *b++ ;
}
*temp = '\0';
printf("%s",dest);of course you need now to generalize the code (ad remember to free
dest
when you no longer need it) :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]