|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
//about_const.h
#ifndef ABOUT_CONST_H
#define ABOUT_CONST_H
//字符串复制
char *MyStrcpy(char *strDest, char const *strSrc);
#endif
/////////////////////////////////////////////////////////
#include <STDIO.H>
#include <STRING.h>
#include "about_const.h"
int main()
{
char source[] = "source string";
char destination[32];
int const x = 123;
int *q = &x;
printf("x= %d\n", x);
*q = 0;
printf("x= %d\n", x);
printf("The length of destination is:%d\n",
strlen(MyStrcpy(destination, source)));
printf("The source string is:%s\n", source);
printf("The destination string is:%s\n", destination);
return 0;
}
char *MyStrcpy(char *strDest, char const *strSrc)
{
char *address = strDest;
if ((strDest != NULL) && (strSrc != NULL))
{
while((*strDest++ = *strSrc++) != '\0');
strSrc = NULL;
return address;
}
else
{
return address;
}
}
|
|