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. Get Started with the Google Fonts API

    Get Started with the Google Fonts API This guide explains how to use the Google Fonts API to add fon ...

  2. POJ 1958 Strange Towers of Hanoi

    Strange Towers of Hanoi Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 3784 Accepted: 23 ...

  3. xml和json格式输出

    <?php   class Response{     const JSON ='json';       /*     * 按综合方式输出通信数据     * @param integer $ ...

  4. js fetch api

    MDN fatch 返回的对象 type string url string redirected boolean status number ok boolean statusText string ...

  5. AngularJS基础02 神奇的数据绑定(Binding)

    作者:arccosxy  转载请注明出处:http://www.cnblogs.com/arccosxy/ 上一节,我们在JS中声明一个scope变量然后在HTML直接访问它,这非常的酷.但是Angu ...

  6. Android必学-异步加载+Android自定义View源码【申明:来源于网络】

    Android必学-异步加载+Android自定义View源码[申明:来源于网络] 异步加载地址:http://download.csdn.net/detail/u013792369/8867609 ...

  7. 解决Hibernate:could not initialize proxy - no Session(申明:来源于网络)

    解决Hibernate:could not initialize proxy - no Session 地址:http://blog.csdn.net/chenssy/article/details/ ...

  8. Codeforces 219C - Color Stripe - [DP]

    题目链接:http://codeforces.com/problemset/problem/219/C 题意: 给你 $n$ 个方块排成水平一排,每个方块都涂上 $k$ 种颜色中的一种.要求对尽量少的 ...

  9. [No000012F]WPF(7/7) - 样式,触发器和动画

    WPF Tutorial : Beginning [^] WPF Tutorial : Layout-Panels-Containers & Layout Transformation [^] ...

  10. background属性解释

    如background: url(images/img1.jpg) no-repeat 0 0; 其中的 0 0,前一个是横坐标上的数,后一个表示纵坐标上的数,而很神奇的是,作为参考的坐标原点不是永远 ...