【C语言】将两个字符串连接起来

#include<stdio.h>
int main()
{
    char s1[100] = "I ";
    char s2[100] = "am a student";
    int i, j, n;
    for (i = 0; s1[i] != '\0'; i++)
        ;
    n = i;
    for (j = 0; s2[j] != '\0'; j++)
    {
        s1[n] = s2[j];
        n = n + 1;
    }
    s1[n] = '\0';
    printf("%s", s1);


} 

 

posted @ 2019-12-01 14:10  木子欢儿  阅读(7509)  评论(0编辑  收藏  举报