C语言基础 -48 函数_函数与字符数组

#include  
#include 

char *mystrcpy(char *dest, const char *src)
{
	char *ret = dest;
	if(dest != NULL && src != NULL)
		while((*dest++ = *src++) != '\0');
		
	return ret;
}

int main()
{
	char str1[] = "helloworld";
	char str2[128];
	
	mystrcpy(str2,str1);
	
	puts(str2);
	
	exit(0); 
}
#include  
#include 

char *mystrcpy(char *dest, const char *src)
{
	char *ret = dest;
	if(dest != NULL && src != NULL)
		while((*dest++ = *src++) != '\0');
		
	return ret;
}

char *mystrncpy(char *dest, const char *src,size_t n)
{
	int i;
	for(i = 0; i < n && (dest[i] = src[i]); i++)
		;
		
	for(; i

 

你可能感兴趣的:(Linux,C编程)