参考QNX官网
#include <string.h>
char* strcpy( char* dst, const char* src );
char* strcat( char* dst, const char* src );
strcpy()函数的功能是将src指针指向的字符串复制到dst指向的数组中。(src会替换掉dst指向的字符)
strcat()函数的功能是将src指针指向的字符串添加到dst指针指向的字符串后面,src第一个字符从dst指针结尾处开始。(src和dst指向的字符会拼接到一起)
Example
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main( void )
{
char buffer[80];
strcpy( buffer, "Hello " );
strcat( buffer, "world" );
printf( "%s\n", buffer );
return 0;
}
void Test::WriteData()
{
std::string log = "Hellow World";
char* buff = new char[log.length() + 1];
strcpy(buff, log.c_str());
}
Output
Hellow World