码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • 【C语法学习】27 - strncat()函数


    文章目录

    • 1 函数原型
    • 2 参数
    • 3 返回值
    • 4 使用说明
    • 5 示例

    1 函数原型

    strncat():将src指向的字符串的前n个字符附加在dest指向的字符串末尾,函数原型如下:

    char *strncat(char *dest, const char *src, size_t n);
    
    • 1

    2 参数

    strncat()函数有三个参数src、dest和n:

    1. 参数src是指向源字符串的指针,类型为char*型;
    2. 参数dest是指向目的字符串的指针,类型为char*型;
    3. 参数n是附加的字符数量,类型为size_t(unsigned int)型。

    3 返回值

    strncat()函数的返回值类型为char*型,返回值为dest。

    4 使用说明

    1. 当src指向的字符串长度小于n,strncat()函数的功能与strcat()函数的功能相同;
    2. 当src指向的字符串长度大于n,将前n个字符附加在dest指向的字符串末尾,然后在拼接后的字符串末尾添加空字符’\0’。

    C语言标准描述如下:

    1. Appends at most count characters from the character array pointed to by src, stopping if the null character is found, to the end of the null-terminated byte string pointed to by dest. 
    2. The character src[0] replaces the null terminator at the end of dest. 
    3. The terminating null character is always appended in the end (so the maximum number of bytes the function may write is count+1).
    4. The behavior is undefined if the destination array does not have enough space for the contents of both dest and the first count characters of src, plus the terminating null character. 
    5. The behavior is undefined if the source and destination objects overlap. 
    6. The behavior is undefined if either dest is not a pointer to a null-terminated byte string or src is not a pointer to a character array,
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    5 示例

  • 相关阅读:
    【FFmpeg】ffmpeg使用drawtext过滤器在视频上叠加文字
    爬虫时如何利用BeautifulSoup获取我们需要的数据?
    Awesome Uplift Modeling【如何学习因果推断、因果机器学习和Uplift建模?All in here】
    AttributeError: ‘Prophet‘ object has no attribute ‘stan_backend‘解决方案
    9.2.2 TIME类型
    【Linux】安装与配置虚拟机及虚拟机服务器坏境配置与连接---超详细教学
    vue在线查看pdf文件
    kube-scheduler addAllEventHandlers
    充分统计量,因子分解定理与Rao-Blackwewll定理
    配电能效管理系统在纺织厂能耗成本的研究
  • 原文地址:https://blog.csdn.net/XDUryan/article/details/134537050
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号