• <bdo id='vWfAp'></bdo><ul id='vWfAp'></ul>
    1. <small id='vWfAp'></small><noframes id='vWfAp'>

        <i id='vWfAp'><tr id='vWfAp'><dt id='vWfAp'><q id='vWfAp'><span id='vWfAp'><b id='vWfAp'><form id='vWfAp'><ins id='vWfAp'></ins><ul id='vWfAp'></ul><sub id='vWfAp'></sub></form><legend id='vWfAp'></legend><bdo id='vWfAp'><pre id='vWfAp'><center id='vWfAp'></center></pre></bdo></b><th id='vWfAp'></th></span></q></dt></tr></i><div id='vWfAp'><tfoot id='vWfAp'></tfoot><dl id='vWfAp'><fieldset id='vWfAp'></fieldset></dl></div>
        <legend id='vWfAp'><style id='vWfAp'><dir id='vWfAp'><q id='vWfAp'></q></dir></style></legend>
        <tfoot id='vWfAp'></tfoot>
      1. C++ 从 LPCTSTR 转换为 const char *

        c++ convert from LPCTSTR to const char *(C++ 从 LPCTSTR 转换为 const char *)

        • <bdo id='mZzwL'></bdo><ul id='mZzwL'></ul>

          <small id='mZzwL'></small><noframes id='mZzwL'>

            <i id='mZzwL'><tr id='mZzwL'><dt id='mZzwL'><q id='mZzwL'><span id='mZzwL'><b id='mZzwL'><form id='mZzwL'><ins id='mZzwL'></ins><ul id='mZzwL'></ul><sub id='mZzwL'></sub></form><legend id='mZzwL'></legend><bdo id='mZzwL'><pre id='mZzwL'><center id='mZzwL'></center></pre></bdo></b><th id='mZzwL'></th></span></q></dt></tr></i><div id='mZzwL'><tfoot id='mZzwL'></tfoot><dl id='mZzwL'><fieldset id='mZzwL'></fieldset></dl></div>
          • <legend id='mZzwL'><style id='mZzwL'><dir id='mZzwL'><q id='mZzwL'></q></dir></style></legend>
            • <tfoot id='mZzwL'></tfoot>
                <tbody id='mZzwL'></tbody>

                1. 本文介绍了C++ 从 LPCTSTR 转换为 const char *的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在 MSVC2008 MFC 中有这个问题.我正在使用 unicode.我有一个函数原型:

                  MyFunction(const char *)

                  我称之为:

                  MyfunFunction(LPCTSTR wChar).

                  <块引用>

                  错误:无法将参数 1 从LPCTSTR"转换为const char *"

                  如何解决?

                  解决方案

                  由于您使用的是 MFC,您可以轻松地让 CString 进行从 charTCHAR 的自动转换>:

                  MyFunction(CString(wChar));

                  无论您的原始字符串是基于 char 还是基于 wchar_t,这都有效.

                  看来我最初的回答与您所要求的相反.轻松修复:

                  MyFunction(CStringA(wChar));

                  CStringACString 的一个版本,它专门包含 char 字符,而不是 TCHAR.还有一个 CStringW 保存 wchar_t.

                  I have this problem in MSVC2008 MFC. Im using unicode. I have a function prototype:

                  MyFunction(const char *)
                  

                  and I'm calling it:

                  MyfunFunction(LPCTSTR wChar). 
                  

                  error:Cannot Convert Parameter 1 From 'LPCTSTR' to 'const char *'

                  How to resolve it?

                  解决方案

                  Since you're using MFC, you can easily let CString do an automatic conversion from char to TCHAR:

                  MyFunction(CString(wChar));
                  

                  This works whether your original string is char or wchar_t based.

                  Edit: It seems my original answer was opposite of what you asked for. Easily fixed:

                  MyFunction(CStringA(wChar));
                  

                  CStringA is a version of CString that specifically contains char characters, not TCHAR. There's also a CStringW which holds wchar_t.

                  这篇关于C++ 从 LPCTSTR 转换为 const char *的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  What is inside .lib file of Static library, Statically linked dynamic library and dynamically linked dynamic library?(静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么?)
                  How do I load a C DLL from the SXS in Python?(如何从 Python 中的 SXS 加载 C DLL?)
                  Can Cython code be compiled to a dll so C++ application can call it?(Cython 代码可以编译成 dll 以便 C++ 应用程序可以调用它吗?)
                  Delay Loading DLLs(延迟加载 DLL)
                  Throwing C++ exceptions across DLL boundaries(跨 DLL 边界抛出 C++ 异常)
                  Loading a dll from a dll?(从 dll 加载 dll?)

                    <tbody id='oZUXM'></tbody>
                  <legend id='oZUXM'><style id='oZUXM'><dir id='oZUXM'><q id='oZUXM'></q></dir></style></legend>
                2. <i id='oZUXM'><tr id='oZUXM'><dt id='oZUXM'><q id='oZUXM'><span id='oZUXM'><b id='oZUXM'><form id='oZUXM'><ins id='oZUXM'></ins><ul id='oZUXM'></ul><sub id='oZUXM'></sub></form><legend id='oZUXM'></legend><bdo id='oZUXM'><pre id='oZUXM'><center id='oZUXM'></center></pre></bdo></b><th id='oZUXM'></th></span></q></dt></tr></i><div id='oZUXM'><tfoot id='oZUXM'></tfoot><dl id='oZUXM'><fieldset id='oZUXM'></fieldset></dl></div>
                  • <bdo id='oZUXM'></bdo><ul id='oZUXM'></ul>
                      • <small id='oZUXM'></small><noframes id='oZUXM'>

                          <tfoot id='oZUXM'></tfoot>