zoukankan      html  css  js  c++  java
  • CString转char[]函数

    /*  
     
     * 函数名: CString2Char  
     
     * 参数1: CString str                 待转换字符串  
     
     * 参数2: char ch[]                       转换后将要储存的位置  
     
     * 将Unicode下的CString转换为char*  
     
    */  
     
     void CString2Char(CString str, char ch[])   
     
    {   
     
        int i;   

        char *tmpch;   
     
        int wLen = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);//得到Char的长度    
     
         tmpch = new char[wLen + 1];                                             //分配变量的地址大小    
     
        WideCharToMultiByte(CP_ACP, 0, str, -1, tmpch, wLen, NULL, NULL);       //将CString转换成char*    
     
             
     
        for(i = 0; tmpch[i] != '\0'; i++) ch[i] = tmpch[i];   
     
        ch[i] = '\0';   
     
     }  

  • 相关阅读:
    Linux中的邮件发送
    Python学习笔记18-发送邮件
    Ansible学习笔记
    eclipse使用maven打包时去掉测试类
    CentOS安装redis
    spring boot 部署
    sprint boot 配置
    spring-boot 学习笔记一
    不要容忍破窗户
    阿里云安装Oracle
  • 原文地址:https://www.cnblogs.com/hailexuexi/p/2257772.html
Copyright © 2011-2022 走看看