# include "stdafx. H"
# include "stdio.h"
# include "stdlib. H"
# include "assert. H"
#include
//# include & lt; Cstring>
//using namespace STD.
Char * strcpy (strDest, char * const char * strSrc)
{
Assert ((strDest!=NULL) & amp; & (strSrc!=NULL));
Char * address=strDest;
While (strSrc++ strDest++=(* *)!='\ 0')
{
Return NULL;
}
The return address.
}
Int _tmain (int arg c, _TCHAR * argv [])
{
Char s1 [6]="China";
Char s2 [3]="ch";
Strcpy (s1, s2);
system("pause");
return 0;
}
Why do I add # include & lt; String> Don't use to write their own strcopy () function doesn't understand
Remove the # include & lt; String> Can be compiled
CodePudding user response:
The string is not already have a strcpy?CodePudding user response:
The function name repetition, change a name, or use your own strcpy namespace namespace definition,CodePudding user response:
The nuptial with namespace definition once, use;; Space scope qualifier pointed outCodePudding user response:
Not I use system directly strcopy () will also be an errorCodePudding user response:
# include "stdafx. H"# include "stdio.h"
# include "stdlib. H"
# include "assert. H"
#include
#include
using namespace std;
Int _tmain (int arg c, _TCHAR * argv [])
{
Char s1 [10]="ww";
Char s2 [3]="ch";
Strcpy (s1, s2);
Free (s1);
S1=NULL;
system("pause");
return 0;
}
This also not line
CodePudding user response:
Write their names all changed,CodePudding user response:
The most direct method, change yourself to write the function nameCodePudding user response: