strcat函数

 原型:char  *strcat  ( char  *dest, const  char  *src)

   用法:#include  <string.h>

   功能:连接两个字符串;strcat()会将参数src字符串 拷贝到 参数dest所指的字符串尾。 第一个参数dest要有足够的空间来容纳要拷贝的字符串。

   说明:strcat()返回dest的字符串起始地址。

#include<iostream>
using namespace std;
 
int main()
{
    char p1[10] = "abcd", *p2, str[10] = "xyz";
    
    p2 = "ABCD";
    strcpy(str + 2, strcat(p1 + 2, p2 + 1));
    printf(" %s", str);
}

 

答案:xycdBCD

 

 

 

 

posted @ 2017-02-07 10:46  VZXM  阅读(290)  评论(0编辑  收藏  举报