2021年4月4日星期日

How to copy char array in C without inner function

This is my code

char function(char *dst)  {      int i;      char *arr;        i = 0;      while(dst[i] != '\0')      {          arr[i] = dst[i];          i++;      }      dst[i] != '\0'      return(arr);  }    int main(void)  {      char a[] ="asdf"      printf("%s", function(a);  }    

I want to copy *dst to empty *arr but my code didn't work. I can't understand. How can I copy array without inner function in C(ex_strcpy, memspy....) Thank you

https://stackoverflow.com/questions/66947864/how-to-copy-char-array-in-c-without-inner-function April 05, 2021 at 11:20AM

没有评论:

发表评论