zoukankan      html  css  js  c++  java
  • C++ 中TCHAR字符串数组转化为Char类型数组

     1 #include <stdio.h> 
     2 #include <tchar.h>  
     3 
     4 char* UnicodeToAnsi( const wchar_t* szStr ) 
     5 { 
     6  int nLen = WideCharToMultiByte( CP_ACP, 0, szStr, -1, NULL, 0, NULL, NULL ); 
     7  if (nLen == 0) 
     8  { 
     9     return NULL; 
    10  } 
    11  char* pResult = new char[nLen]; 
    12  WideCharToMultiByte( CP_ACP, 0, szStr, -1, pResult, nLen, NULL, NULL ); 
    13  return pResult; 
    14  } 
    15 
    16 void  main(){
    17 
    18     TCHAR msg[100]; 
    19     swprintf_s(msg, L"sjlkjdkld"); 
    20     char *str=UnicodeToAnsi(msg);
    21 
    22 }
  • 相关阅读:
    51Nod
    51Nod
    51Nod
    51Nod
    51Nod
    51Nod
    51Nod
    51Nod --1133 不重叠的线段
    bzoj2440: [中山市选2011]完全平方数
    第三章:基本HTML结构
  • 原文地址:https://www.cnblogs.com/kire/p/4428821.html
Copyright © 2011-2022 走看看