It works for me. How are you defining your actual parameters input and output in the program that calls it?
Here's mine:
Code:
#include <iostream>
using namespace std;
int main()
{
char* StrCpy(char* output, char* input);
char outstr[100];
//char instr[100] = "This is a test"; // try this : still works
char instr[100] = "ASD";
cout << "instr = <" << instr << ">" << endl;
StrCpy(outstr, instr);
cout << "outstr = <" << outstr << ">" << endl;
cout << endl << "Now, you enter a word to copy: ";
cin >> instr;
cout << "instr = <" << instr << ">" << endl;
StrCpy(outstr, instr);
cout << "outstr = <" << outstr << ">" << endl;
return 0;
}
char* StrCpy(char* output, char* input)
{
if (*input != NULL)
{
*output = *input;
*output++;
*input++;
StrCpy(output,input);
}
else *output= NULL;
return output;
}
Tested on Windows XP with Borland bcc, Microsoft Visual C++, and GNU g++ (Cygwin).
Tested on Linux with GNU g++.
Dave