Convert char to TCHAR* argv[]

前端 未结 2 1570
栀梦
栀梦 2020-12-21 02:50

How can I input text into TCHAR* argv[]?

OR: How can I convert from char to TCHAR* argv[]?

char randcount[] =          


        
相关标签:
2条回答
  • 2020-12-21 03:05

    /*This code did TCHAR in my project without A2T or any other converters. Char text is a some kind of array. So we can take letters one by one and put them to 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;
       }
    
    0 讨论(0)
  • 2020-12-21 03:13

    One way to do is:

    char a[] = "Hello world";
    USES_CONVERSION;
    TCHAR* b = A2T(a);
    
    0 讨论(0)
提交回复
热议问题