C语言:字符数组相互赋值方法

#include <stdio.h>
#include <string.h>
main()
{
    char ab[100]="asdfasd",ac[100];
    printf("%d %d\n",ab,ac); 
    //ac=ab 由于ab,ac分别为两个数组的起始地址,所以该句有语法问题
    //字符数组相互赋值可用strcpy(ac,ab)
    strcpy(ac,ab); 
    puts(ac);
    getchar();
 }

 

posted @ 2022-10-06 16:32  myrj  阅读(331)  评论(0编辑  收藏  举报