strncat函数

2007年03月15日 20:32:00

阅读数:13676

函数原型:extern char *strncat(char *dest,char *src,int n)

参数说明:src为源字符串,dest为目的字符串,n为指定的src中的前n个字符。
       
所在库名:#include <string.h>
 
函数功能:把src所指字符串的前n个字符添加到dest结尾处,覆盖dest结尾处的'/0',实现字符串连接。
 
返回说明:返回指针,连接后的字符串。

其它说明:暂时无。

实例:

#include <string.h>
#include <stdio.h>
int main()
{
    char str1[100]="SKY2098,persist IN DOING AGAIN!";
    char *str2="sky2098,must be honest!";
    int n=15;
    char *strtemp; 
    strtemp=strncat(str1,str2,n);   //将字符串str2中的前n个字符连接到str1的后面
    printf("The string strtemp is:  %s  ", strtemp);
    return 0;
}

在VC++ 6.0 编译运行:

实现了指定某个字符串中的字符连接到另一个字符串上的操作。

strcat()函数

2016年07月28日 15:44:28

阅读数:54933
将两个char类型链接。
char d[20]="GoldenGlobal"; char *s="View"; strcat(d,s);
结果放在d中
printf("%s",d);
输出 d 为 GoldenGlobalView (中间无空格)
d和s所指内存区域不可以重叠且d必须有足够的空间来容纳s的字符串。

返回指向d的指针

C函数

编辑

原型

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

用法

#include <string.h>
在C++中,则存在于<cstring>头文件中。

功能

把src所指字符串添加到dest结尾处(覆盖dest结尾处的'\0')。

说明

src和dest所指内存区域不可以重叠且dest必须有足够的空间来容纳src的字符串。
返回指向dest的指针

strncat、strcat的更多相关文章

  1. strcpy、strncpy、strlen、memcpy、memset、strcat、strncat、strcmp、strncmp,strchr

    1.strcpy #include<stdio.h> #include<assert.h> char *mystrcpy(char *dest, const char *src ...

  2. 转:C语言字符串操作函数 - strcpy、strcmp、strcat、反转、回文

    转自:C语言字符串操作函数 - strcpy.strcmp.strcat.反转.回文 C++常用库函数atoi,itoa,strcpy,strcmp的实现 作者:jcsu C语言字符串操作函数 1. ...

  3. 不使用库函数、自己编写的(strlen、strcpy、strcmp、strcat、memcmp、memcpy、memmove)

    不使用库函数.自己编写的(strlen.strcpy.strcmp.strcat.memcmp.memcpy.memmove) //求字符串长度的函数 int my_strlen(const char ...

  4. strlen、strcpy、strcat的实现

    概念: 1.strlen:strlen所作的仅仅是一个计数器的工作,它从内存的某个位置(可以是字符串开头,中间某个位置,甚至是某个不确定的内存区域)开始扫描,直到碰到第一个字符串结束符'\0'为止,然 ...

  5. 手写atoi、strcpy、strcat

    一:实现atoi函数 1 #include<iostream> 2 3 using namespace std; 4 5 int atoi_my(const char *str) 6 { ...

  6. 逆向 string.h 函数库 strlen、memchr、strcat 函数

    strlen 函数 主要功能:返回字符串的长度 C/C++ 实现: #include <iostream> #include <stdio.h> #include <st ...

  7. Linux C 字符串函数 strlen()、strcat()、strncat()、strcmp()、strncmp()、strcpy()、strncpy() 详解

      strlen(返回字符串长度) 表头文件 #include <string.h> 定义函数 size_t strlen(const char *s); 函数说明 strlen()用来计 ...

  8. c语言中几个常见的库函数strlen、strcmp、strcat、strcpy、strncpy、memset、memcpy、memmove、mmap

    1.strlen() 1)计算给定字符串的长度,不包括’\0’在内 unsigned int strlen(const char *s) { assert(NULL != s);//如果条件不满足,则 ...

  9. C语言字符串操作函数 - strcpy、strcmp、strcat、反转、回文

    原文:http://www.cnblogs.com/JCSU/articles/1305401.html C语言字符串操作函数 1. 字符串反转 - strRev2. 字符串复制 - strcpy3. ...

随机推荐

  1. C# Hashtable

    哈希表(Hashtable) 在.NET Framework中,Hashtable 是 System.Collections 命名空间提供的一个容器,用于处理和表现类似 key-value 的键值对, ...

  2. IOS多线程处理

    http://www.jianshu.com/p/0b0d9b1f1f19 首页专题下载手机应用 显示模式登录     注册登录 添加关注 作者 伯恩的遗产2015.07.29 00:37* 写了35 ...

  3. Spark2 Random Forests 随机森林

    随机森林是决策树的集合. 随机森林结合许多决策树,以减少过度拟合的风险. spark.ml实现支持随机森林,使用连续和分类特征,做二分类和多分类以及回归. 导入包 import org.apache. ...

  4. xcode reset 删除重新安装

    Type "rm -rf ~/Library/Application Support/Xcode" and press "Enter." This remove ...

  5. myeclipse编译弹框:The builder launch configuration could not be found

    myEclipse 每次编译时报 "The builder launch configuration could not be found" 的弹框:不影响项目编译启动,但是弹框挺 ...

  6. .NET Core开发日志——Dapper与MySQL

    Dapper作为.NET生态中广为人知的轻量级ORM类库在.NET Core里仍能被有效利用,并且其不但可以连通SQL Server数据库还提供对其它数据库,比如MySQL的支持.这里试验了一下通过D ...

  7. CCPC-Wannafly Winter Camp Day4 Div1 - 置置置换 - [DP]

    题目链接:https://zhixincode.com/contest/18/problem/G?problem_id=265 题目描述 wls有一个整数 $n$,他想请你算一下有多少 $1...n$ ...

  8. c# 字符串转为数字

    C#判断输入是否数字 /// <summary> /// 判断输入是否数字 /// </summary> /// <param name="num"& ...

  9. 使用c#反射实现接口可视化调试页面

    直接上代码,引用CommTools.dll.包括aspx显示页面和aspx.cs获取反射数据源代码 using System; using System.Collections.Generic; us ...

  10. [daily][cgroup] 使用cgroup限制进程的CPU占用

    参考: https://segmentfault.com/a/1190000008323952 1. 找到cgroup设置的地方. [root@D128 ~]# mount -l |grep cpu ...