不解释.
int main(){
int i;
char * msg =  (char *)malloc(6);
char buff[] = "2mxbc";
char onechar;
for(i=0;i <  strlen(buff);i++)
   printf("the %d char is %c",i,buff[i]);

printf("the length of buff is %d",strlen(buff));

memcpy((char *)msg,buff,strlen(buff));
for(i=0;i < = strlen(buff);i++)
    printf("the %d char is %c",i,msg[i]);

for(i=0;i <  strlen(buff)-1;i++)
    msg[i]=msg[i+1];

for(i=0;i <  strlen(buff);i++)
    printf("After copy the %d char is %c",i,msg[i]);

strncpy(&onechar,&msg[4],1);
printf("the char is %d",onechar);
return 0;
}

相关文章:

  • 2021-09-20
  • 2021-09-20
  • 2021-09-20
  • 2021-12-12
  • 2022-12-23
  • 2022-01-17
  • 2022-12-23
  • 2021-05-24
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-20
  • 2021-09-20
相关资源
相似解决方案