strncpy有三个参数 第一个参数是要替换的字符串 第二个是源字符串,第三个替换的字符个数
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int main()
{
char ch1[10]="gh";
char ch2[]="abcdef";
strncpy(ch1,ch2,3);
//ch1要替换的字符安串,ch2源字符串,要替换的字符个数
cout<<ch1<<endl;
return 0;
}