用字符指针编程实现两个字符串的拷贝。注:不允许使用字符串拷贝函数!
请使用以下函数编程实现。
void MyStrcpy( char *dstStr, char *srcStr )
***输入提示:"Please enter a string:\n"
***输入格式要求:无格式要求
***输出格式要求:"The copy is:%s"
#include <stdio.h>
void MyStrcpy(char *dstStr, char *srcStr); //1
main()
{
char a[80], b[80];
printf("Please enter a string:\n");
gets(a); //1
MyStrcpy(b, a); //1
printf("The copy is:%s", b);
}
void MyStrcpy(char *dstStr, char *srcStr)
{
while (*srcStr != '\0') //1
{
*dstStr = *srcStr; //1
srcStr++; //1
dstStr++; //1
}
*dstStr = '\0'; //1
}