作用
将字符串复制到指定的字符串缓冲区。
函数
LPSTR lstrcpyA(LPSTR lpString1, LPCSTR lpString2);
参数
lpString1
类型:LPTSTR
一个缓冲区,用于接收由 lpString2 参数指向的字符串的内容。 缓冲区必须足够大才能包含字符串,包括终止 null 字符。
lpString2
类型:LPTSTR
要复制的以 null 结尾的字符串。
返回值
类型:LPTSTR
如果函数成功,则返回值为指向缓冲区的指针。
如果函数失败,则返回值 NULL,lpString1 可能不会以 null 结尾。
支持
最低支持系统版本 | Windows 2000 Professional |
最低支持服务器版本 | Windows 2000 Server |
头文件 | winbase.h (包括 Windows.h) |
库 | Kernel32.lib |
dll | Kernel32.dll |
例子
#include "windows.h"
int _tmain(int argc, _TCHAR* argv[])
{
char ch1[48] = "ABC123";
char ch2[48] = { 0 };
char* result_ch = lstrcpyA(ch2, ch1);
printf("结果1:%s\n",ch2);
printf("结果2:%s\n",result_ch);
system("pause");
return 0;
}