Difference between strncpy and memcpy?

前端 未结 5 1982
粉色の甜心
粉色の甜心 2020-12-05 03:10

How can i access s[7] in s?

I didn\'t observe any difference between strncpy and memcpy. If I want to print the o

5条回答
  •  时光说笑
    2020-12-05 03:57

    Strncpy will copy up to NULL even you specified the number of bytes to copy , but memcpy will copy up to specified number of bytes .

    printf statement will print up to NULL , so you will try to print a single charater , it will show ,

    printf("\t%c %c %c\t",s[7],str[7],str1[7]);
    

    OUTPUT

      7              7
    

提交回复
热议问题