代码改变世界

学习language C

  Jeff  阅读(418)  评论(0编辑  收藏  举报
不解释.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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;
}
点击右上角即可分享
微信分享提示