C copy string


from http://chiakie.pixnet.net/blog/post/3043315-%5Bc-language%5D-strcat%28-%29-%E7%9A%84%E4%BB%8B%E7%B4%B9%E8%88%87%E6%98%93%E7%99%BC%E7%94%9F%E7%9A%84%E9%8C%AF%E8%AA%A4

char *s1 = (char *)malloc(20);
char *s2 = "world!!";
strcpy(s1, "Hello ");
strcat(s1, s2);



or

void AddString(char *result,  char *strStart,  char *strEnd)
{

    strcpy(result,strStart); // copy string one into the result.
    strcat(result,strEnd); // append string two to the result.

}


        char repeatXml[4000];
        for(i=0; i < node->repeatXmlNum; i++)
        {
            AddString(repeatXml,repeatXml,  " ");
            AddString(repeatXml,repeatXml,  node->repeatXml[i]);
        }

留言

熱門文章