Q:

Crash while trying to concatenate two strings

#include<iostream>

using namespace std;

char *concat(char *string1,char *string2)
{
          char *stringfinal=new char[strlen(string1)+strlen(string2)+2];
          stringfinal=string1;
          char *dest=new char[strlen(string1)+strlen(string2)+2];
          dest = stringfinal;
          while(*dest != '\0')
          {
                      dest++;
          }

          *dest=' ';  // Point 1

          while(*string2 != '\0')        
               *dest++=*string2++;  //Point2
          *dest='\0';
          return stringfinal; 

}

int main()
{

    char *str1="Anurag";
    char *str2="Jain";

    char *strfinal = new char[strlen(str1)+strlen(str2)+2];
    strfinal=concat(str1,str2);

    cout<<strfinal;
    cin.get();

}

A:

Your problem is that you seem to think that
stringfinal=string1

and 
dest = stringfinal;

are doing string copies, whereas they're actually just reasigning the dest and stringfile pointers to point somewhere else (and immediately losing the memory you've just new'd).
You probably want strcpy(stringfile, string1) instead.
Even with this error fixed, this not really a very shining example of the way people write C++ nowadays.  You would almost certainly be better-off using std::string, which would do all this string/pointer/allocation stuff properly for you, leaving you to think about more important stuff.
But if you're just trying to understand what's behind built-in string classes, then more power to you...

A:

The first problem that I see is the second line here:
char *stringfinal=new char[strlen(string1)+strlen(string2)+2];
stringfinal=string1; //problematic line

First you allocate memory and the variable stringfinal holds this memory. And then you overwrite this variable with the memory held by string1. Your newly allocated memory gone, and the problem starts right from here, the second line.
And similar mistake here also:
char *dest=new char[strlen(string1)+strlen(string2)+2];
dest = stringfinal;

The newly allocated memory held by dest is gone the moment you overwrite it with stringfinal.
Anyway, you should be using std::string as:
std::string string1;
std::string string2;
//...
std::string stringfinal = string1 +"  " + string2;

If not std::string, you should be using std::strcpy and std::strcat instead of manual loop, as:
char *concat(char *string1,char *string2)
{
    char *stringfinal=new char[strlen(string1)+strlen(string2)+3];
    std::strcpy(stringfinal,string1);                      //^^^ note this!
    std::strcpy(stringfinal, "  ");
    std::strcat(stringfinal,string2);
    return stringfinal;
}

