#include<stdio.h>
#include<assert.h>
char* my_strcpy(char *dest,const char* source){
assert(dest!=NULL||source!=NULL);
//store the address start of the dest string
char* res=dest;
while((*dest++=*source++)!='\0');
return res;
}
int main(){
char src[10]="qwertyuio";
char dest[13];
printf("%s",my_strcpy(dest,src));
return 0;
}
char * strncpy ( char * destination, const char * source, size_t num );
#include<stdio.h>
char *my_strncpy(char * dest,const char * source,size_t num){
char *res=dest;
while(num--&&(*dest++=*source++)!='\0');
while(num--)
*dest++='\0';
return res;
}
int main(){
char src[10]="qwertyuio";
char dest[13];
printf("%s",my_strncpy(dest,src,12));
return 0;
}