学习language C
2011-05-26 15:29 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; } |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步