4

如何将文本输入TCHAR* argv[]

或者:我怎样才能从 转换charTCHAR* argv[]

char randcount[] = "Hello world";

TCHAR* argv[];

argv = convert(randcount);
4

2 回答 2

7

一种方法是:

char a[] = "Hello world";
USES_CONVERSION;
TCHAR* b = A2T(a);
于 2010-04-16T12:04:35.613 回答
0

/*此代码在我的项目中执行 TCHAR,没有 A2T 或任何其他转换器。字符文本是某种数组。所以我们可以一个一个地取字母,然后把它们放到 TCHAR 中。*/

    #include <iostream>
   TCHAR* Converter(char* cha)    
   {
       int aa = strlen(cha);
       TCHAR* tmp = new TCHAR[aa+1];
       for(int i = 0; i< aa+1; i++)
          {
            tmp[i]=cha[i];
          }
       return tmp;
   }

   int main()
   {
       char* chstr= new char[100];
       chstr = "char string";
       TCHAR* Tstr = new TCHAR[100];
       //Below function "Converter" will do it
       Tstr = Converter(chstr);
       std::cout<<chstr<<std::endl;
       std::wcout<<Tstr<<std::endl;
   }
于 2017-05-24T19:04:30.723 回答