璐's profile石在帅的小璐PhotosBlogListsMore Tools Help

Blog


    July 20

    NB的人儿啊

    困扰了我一个周末的问题,终于在网上找到了答案,牛人儿啊,zz:
     
    在VS2005,2008下如何将LPCTSTR转换为const char *?
     

    其实也就是如何将const wchar_t * 转换为 const char *。主要是在上篇那个判断文件访问的函数_access中传入的是const char所以报错,错误就是“不能将参数 1 从“LPCTSTR”转换为“const char *” ”

    方法是:

    char str[1024];
    wsprintfA(str, "%S ",lpWideChars);

    注意此处是wsprintfA而不是wsprintf,我在msdn中没找到wsprintfA。还有就是%S中的S是大写的。表示LPSTR。%s表示LPWSTR。

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks

    The trackback URL for this entry is:
    http://superlulululu.spaces.live.com/blog/cns!9FA35ECFBD5AF4F!745.trak
    Weblogs that reference this entry
    • None