C中的strncat()函数

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

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

小例子:

#include <stdio.h>
#include <string.h>

int main()
{
        char str[100] = "SKY2098, YOU";
        char *str2 = "are the hero!but iuu";
        int n = 15; 
        char *strtemp;
        strtemp = strncat(str, str2, 13 );
        printf("This string strtemp is: %s\n", strtemp);
        return 0;
}
~        

输出为:
This string strtemp is: SKY2098, YOUare the hero!




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值