Append to the end of a Char array in C++

前端 未结 4 1746
我在风中等你
我在风中等你 2021-02-08 14:58

Is there a command that can append one array of char onto another? Something that would theoretically work like this:

//array1 has already been set to \"The dog         


        
4条回答
  •  死守一世寂寞
    2021-02-08 15:25

    You should have enough space for array1 array and use something like strcat to contact array1 to array2:

    char array1[BIG_ENOUGH];
    char array2[X];
    /* ......             */
    /* check array bounds */
    /* ......             */
    
    strcat(array1, array2);
    

提交回复
热议问题