zoukankan      html  css  js  c++  java
  • <六> strcat函数

    strcat函数

    char *strcat(char *dest, const char *src);
    功能:将后面的字符串拼接到前面
    参数:char*传递地址
    返回:返回dest
    注意:dest空间足够大,dest只能传递变量的地址

     1 #include <stdio.h>
     2 #include <string.h>
     3 
     4 int main(int argc, const char *argv[])
     5 {
     6     char a[32] = "hello";
     7     char b[] = "world";
     8     int i = 0,j = 0;     //i:a的下标  j:b的下标
     9 
    10     while(a[i] != '')
    11     {
    12         i++;             //当结束循环是a[i] == ‘’  i == 5 
    13     }
    14 
    15     while(b[j] != '')
    16     {
    17         a[i] = b[j];
    18         i++;
    19         j++;
    20     }
    21 
    22     a[i] = '';
    23     printf("a = %s
    ",a);
    24         //以上是用c对此函数的实现
    25 
    26 //    strcat(a,"beijing");
    27 //    printf("a = %s
    ",a);
    28 //    printf("a = %s
    ", strcat(a,b);
    29 
    30     
    31     return 0;
    32 } 
    青春看起来如此完美, 没空闲去浪费时间。 <我们最后的话——刺猬>
  • 相关阅读:
    chess「dp」
    e[树上主席树]
    d[贪心]
    神盐皇
    LA 8043. ACM-ICPC World Finals 2017 E. Need for Speed
    八数码问题
    UVa 679. Dropping Balls
    关于时间复杂度
    欧拉序列 (Euler Tour)
    莫队算法
  • 原文地址:https://www.cnblogs.com/WangJing0506/p/8541967.html
Copyright © 2011-2022 走看看