如何从 LPCTSTR 转换为 LPSTR? [英] How to convert from LPCTSTR to LPSTR?

查看:39
本文介绍了如何从 LPCTSTR 转换为 LPSTR?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码行:

LPSTR address = T2A((LPTSTR)hostAddress);

我可以将 LPCTSTR hostAddress 转换为 LPSTR 而不使用来自afxpriv.h"的 T2A 宏吗?

Can I convert LPCTSTR hostAddress to LPSTR without using T2A macros from "afxpriv.h"?

推荐答案

这个宏定义在 AtlBase.h 中,使用这个公共的 h 文件,不需要任何依赖.

This macro is defined in in AtlBase.h, use this h-file which is public and doesn't require any dependencies.

更正:AtlBase.h 中没有直接定义,但包含 AtlBase.h 就足以使用字符串转换宏了.

Correction: it is not defined directly in AtlBase.h, but it is enough to include AtlBase.h to use string conversion macros.

这篇关于如何从 LPCTSTR 转换为 LPSTR?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆