Some small problems in C

The first assignment of this course asked me to write some string manipulation functions without using any string library. I got stuck in the function 'mystrcpy'.

I typed following.

/*
* mystrcpy() copies the string pointed to by src (including the terminating character '\0') to the array pointed to by dst.
* Returns: a pointer to the destination string dst.
*/
char *mystrcpy (char *dst, const char *src)
{
  /* Complete the body of the function */

  int i;
  while(src[i]!='\0'){
    dst[i]=src[i];
    i++;
  }
  dst[i]='\0';
  return dst;
}

But terminal showed 'segementation fault'. I'm still thinking about this one.

猜你喜欢

转载自www.cnblogs.com/lyc4891/p/10888058.html
今日推荐