Code:
#include <iostream>
#include <cstring>
using namespace std;
#define MAX_STR_LEN 50//Max length
int stringcopy(char *to, char *from);
int main()
{
char from[MAX_STR_LEN] = {0},
to[MAX_STR_LEN] = {0};
cin.getline(from,MAX_STR_LEN);//Allow line with spaces
stringcopy(to, from);
cout << from << " "<< to;
return 0;
}
int stringcopy(char *to, char *from)
{
while ( (*to = *from) != '\0' )
{
to++;
from++;
}
return 0;
}
You need to create space for the strings.....
Try checking out the string object as defined in the C++ std library....makes life easier