首页 > 代码库 > strncpy实现

strncpy实现

#include<stdio.h>char *my_strncpy(char *dest,char *src,int n){     int i;     for(i=0;i<n && src[i]!=\0;i++)          dest[i] = src[i];     for(;i<n;i++)          dest[i] = \0;     return dest;}char *my_strncpy1(char *dest,const   char   *src,int   n){   int i=0;   char *ret=dest;   while(*src != \0  && i <n)    {       *dest++ = *src++;       i++;     }   return  ret;  }

 

strncpy实现