zoukankan      html  css  js  c++  java
  • 字符串的拼接

    题目:两个字符串,s,t;把t字符串接到s字符串尾,s字符串有足够的空间存放t字符串

    void connect(char *s,const char *t)  //strcat   strlen strcpy strcmp strchr strstr

                                       //形参

    {

    char *q = t;

    char *p =s;

    if(q == NULL)return;  //判断q是否为空指针,为空时可以不用进行拼接操作

    while(*p!='')   //p指针往上偏移,移到’’时跳出此while循环,进入第二个while循环

    {

    p++;

    }

    while(*q!=0)

    {

    *p=*q;              

    p++;

    q++;

    }

    *p = '';     //当p指针到达’’时停止工作

    }

    void main()

    {

    char p[7]="ABC";    //数组名代表指针

    char p2[]="EFG";

    connect(p, p2);     //实参

    printf("%s",p);

    }

  • 相关阅读:
    JavaScrip 数组/字典/循环
    初识javaScript
    css内容补充之其它
    position
    css的存在形式
    CSS选择器
    Html的Head内标签
    Linux设置FQDN
    saltstack 全面介绍
    jQuery文档处理
  • 原文地址:https://www.cnblogs.com/wangliangliang/p/3183062.html
Copyright © 2011-2022 走看看