【Win32 API】 lstrcpyA()

作用

将字符串复制到指定的字符串缓冲区。

函数

cpp 复制代码
LPSTR lstrcpyA(LPSTR  lpString1, LPCSTR lpString2);

参数

lpString1

类型:LPTSTR

一个缓冲区,用于接收由 lpString2 参数指向的字符串的内容。 缓冲区必须足够大才能包含字符串,包括终止 null 字符。

lpString2

类型:LPTSTR

要复制的以 null 结尾的字符串。

返回值

类型:LPTSTR

如果函数成功,则返回值为指向缓冲区的指针。

如果函数失败,则返回值 NULLlpString1 可能不会以 null 结尾。

支持

|---------------|---------------------------|
| 最低支持系统版本 | Windows 2000 Professional |
| 最低支持服务器版本 | Windows 2000 Server |
| 头文件 | winbase.h (包括 Windows.h) |
| | Kernel32.lib |
| dll | Kernel32.dll |

例子

cpp 复制代码
#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;
}
相关推荐
芥子沫20 分钟前
Jenkins常见问题及解决方法
windows·https·jenkins
cpsvps_net17 小时前
美国服务器环境下Windows容器工作负载智能弹性伸缩
windows
甄超锋17 小时前
Java ArrayList的介绍及用法
java·windows·spring boot·python·spring·spring cloud·tomcat
cpsvps20 小时前
美国服务器环境下Windows容器工作负载基于指标的自动扩缩
windows
网硕互联的小客服1 天前
Apache 如何支持SHTML(SSI)的配置方法
运维·服务器·网络·windows·php
etcix1 天前
implement copy file content to clipboard on Windows
windows·stm32·单片机
许泽宇的技术分享1 天前
Windows MCP.Net:基于.NET的Windows桌面自动化MCP服务器深度解析
windows·自动化·.net
非凡ghost1 天前
AMS PhotoMaster:全方位提升你的照片编辑体验
windows·学习·信息可视化·软件需求
mortimer1 天前
一次与“顽固”外部程序的艰难交锋:subprocess 调用exe踩坑实录
windows·python·ai编程
gameatp1 天前
从 Windows 到 Linux 服务器的全自动部署教程(免密登录 + 压缩 + 上传 + 启动)
linux·服务器·windows