2010-04-16 9 views
3

TCHAR* argv[]에 텍스트를 입력하려면 어떻게해야합니까?char를 TCHAR * argv []로 변환하십시오.

또는 char에서 TCHAR* argv[]으로 변환하려면 어떻게해야합니까? 할

char randcount[] = "Hello world"; 

TCHAR* argv[]; 

argv = convert(randcount); 
+0

TCHAR *는 argv [] = _ T (이 "Helloworld"); \t 그것의 보여주는 오류 오류 C2440 : '초기화': 'TCHAR * argv [']와 별개로 시작 부분에 'const char [134]'에서 'TCHAR * []' – Sijith

+0

You can missing " ]'는 TCHAR 포인터의 배열이고 문자열을 할당하려고합니다 : TCHAR * argv [10]; argv [0] = T ("HelloWorld");' – Naveen

+0

이 TCHAR * \t ptszFirstInFile = _T ("sample1.asf")처럼 내 코드; TCHAR * \t ptszSecondInFile = _T ("sample2.asf"); TCHAR * \t ptszOutFile = _T ("xxxx.asf") ; 오류가 발생했습니다 'const char [12]'에서 'TCHAR *'로 변환 할 수 없습니다 – Sijith

답변

4

한가지 방법이다

char a[] = "Hello world"; 
USES_CONVERSION; 
TCHAR* b = A2T(a); 
+0

#include "atlstr.h" – Expenzor

0
#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

다른 사람들이 이해할 수 있도록 코드를 설명해주십시오. – SteveFest

+0

이 코드는 내 프로젝트에서 A2T 또는 다른 변환기없이 TCHAR을 수행했습니다. Char 텍스트는 일종의 배열입니다. 그래서 우리는 편지 하나 하나를 가지고 TCHAR에 넣을 수 있습니다. –

+0

대답에 넣을 수 있습니까? – SteveFest

관련 문제