【头文件】#include <string.h>

【原型】

1

char *strcat(char *dest, const char *src);

【参数】: dest 为目标字符串指针,src 为源字符串指针。

strcat() 会将参数 src 字符串复制到参数 dest 所指的字符串尾部;dest 最后的结束字符 NULL 会被覆盖掉,并在连接后的字符串的尾部再增加一个 NULL。

【注意】 dest 与 src 所指的内存空间不能重叠,且 dest 要有足够的空间来容纳要复制的字符串

【返回值】 返回dest 字符串起始地址。

【实例】连接字符串并输出。

1

2

3

4

5

6

7

8

9

10

11

12

#include <stdio.h>

#include <string.h>

int main ()

{

    char str[80];

    strcpy (str,"these ");

    strcat (str,"strings ");

    strcat (str,"are ");

    strcat (str,"concatenated.");

    puts (str);

    return 0;

}

输出结果:

these strings are concatenated.

Ref:

https://www.cnblogs.com/lvchaoshun/p/5936168.html

软件素材---linux C语言:拼接字符串函数 strcat的用例(与char数组联合使用挺好)的更多相关文章

  1. 软件素材---linux C语言:linux下获取可执行文件的绝对路径--getcwd函数

    //头文件:#include <unistd.h> //定义函数:char * getcwd(char * buf, size_t size); //函数说明:getcwd()会将当前的工 ...

  2. C语言拼接字符串 -- 使用strcat()函数

    [头文件]#include <string.h> [原型] char *strcat(char *dest, const char *src); [参数]: dest 为目标字符串指针,s ...

  3. 软件素材---linux C语言:向文件末尾进行追加数据

    void AppendDataToFile(char* filePath, char* msg) { // 以附加方式打开可读/写的文件, 如果没有此文件则会进行创建,然后以附加方式打开可读/写的文件 ...

  4. C语言常用字符串函数总结

    ANSI C中有20多个用于处理字符串的函数: 注意:const 形参使用了const限定符,表示该函数不会改变传入的字符串.因为源字符串是不能更改的. strlen函数: 函数原型:unsigned ...

  5. C语言常用字符串函数

    string.h头文件中常用的函数 C 库函数 - strcat() char *strcat(char *dest, const char *src) 把 src 所指向的字符串追加到 dest 所 ...

  6. 字符串函数---strcat()与strncat具体解释及实现

    一.strcat()与strncat() strcat():strcat(dest,src);        strcat把src所指向的字符加入到dest结尾处(覆盖原dest结尾处的'\0').并 ...

  7. C语言拼接字符串以及进制转换

    #include<stdio.h> #include<stdlib.h> #include<string.h> char *join1(char *, char*) ...

  8. C语言分割字符串函数strtok

    在编程过程中,有时需要对字符串进行分割.而有效使用这些字符串分隔函数将会给我们带来很多的便利. 下面我将在MSDN中学到的strtok函数做如下翻译. strtok :在一个字符串查找下一个符号 ch ...

  9. c语言中字符串函数的使用

    #include<stdio.h> #include<string.h> /* char s1[]="I am a student"; char s2[20 ...

随机推荐

  1. CF1163E Magical Permutation【线性基,构造】

    题目描述:输入一个大小为\(n\)的正整数集合\(S\),求最大的\(x\),使得能构造一个\(0\)到\(2^x-1\)的排列\(p\),满足\(p_i\oplus p_{i+1}\in S\) 数 ...

  2. (21)打鸡儿教你Vue.js

    组件化思想: 组件化实现功能模块的复用 高执行效率 开发单页面复杂应用 组件状态管理(vuex) 多组件的混合使用 vue-router 代码规范 vue-router <template> ...

  3. realloc()函数

    原型:extern void *realloc(void *mem_address, unsigned int newsize); 参数: mem_address: 要改变内存大小的指针名 newsi ...

  4. python find和index的区别

    如果找不到目标元素,index会报错,find会返回-1 >>> s="hello world" >>> s.find("llo&qu ...

  5. 数组不能用for each ,

    数组不能用for each 不能用这 for(String xkz:xkzzj){ SjshdcDTO sjshdcDTO = cpcyService.findSjshdcDTOById(xkz); ...

  6. 利用python的matplotlib处理计算数据

    #!/usr/bin/python # -*- coding: UTF-8 -*- import numpy as np import matplotlib.pyplot as plt import ...

  7. 并发用户 VS TPS

    TPS模式(吞吐量模式)是一种更好的方式衡量服务端系统的能力. 基本概念: 并发用户数:简称VU ,指的是现实系统中操作业务的用户,在性能测试工具中,一般称为虚拟用户数(Virutal User),注 ...

  8. kubernetes入门学习系列

    一.kubernetes基础概念 初识kubernetes kubernetes相关概念 二.kubernets架构和组件 kubernetes架构 kubernetes单Master架构 kuber ...

  9. Java设计模式之二工厂模式

    在上一篇中我们学习了单例模式,介绍了单例模式创建的几种方法以及最优的方法.本篇则介绍设计模式中的工厂模式,主要分为简单工厂模式.工厂方法和抽象工厂模式. 简单工厂模式 简单工厂模式是属于创建型模式,又 ...

  10. response.getWriter().println和@ResponseBody的比较及同时使用(用于回调函数)

    @RequestMapping(value = "/test", method = { RequestMethod.GET, RequestMethod.POST }) @Resp ...