C题目:将字符串a复制为字符串b,然后输出字符串b

题目:
将字符串a复制为字符串b,然后输出字符串b
代码:
#include <stdio.h>
int main(){
    char a[]="I am love student.",b[20];
    int i;
    for(i=0;*(a+i)!='\0';i++){
        *(b+i) = *(a+i);
    }
    *(b+i) = '\0';

    printf("string a is : %s\n",a);
    printf("string b is :%s\n",b);
    for(i=0;b[i]!='\0';i++){
        printf("%c",*(a+i));
    }
    printf("\n");
    return 0;
}
结果:
string a is : I am love student.
string b is :I am love student.
I am love student.

Process returned 0 (0x0)   execution time : 0.012 s
Press any key to continue.
posted @ 2024-11-21 00:22  昵-称  阅读(26)  评论(0)    收藏  举报