Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. string concatenation using pointer

string concatenation using pointer

Scheduled Pinned Locked Moved C / C++ / MFC
help
21 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C CPallini

    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]

    H Offline
    H Offline
    hrishiS
    wrote on last edited by
    #21

    Oh thanks a lot...its working fine... I have to increase my knowledge towards pointer

    ----------------------------- I am a beginner

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups