2014-11-12 5 views
0

".rels"파일 이름을 추가하려면 xmlChar * 문자열을 연결하려고합니다. 어떤 이유로, 나는 오류를 참조하십시오 나는 모두가 XMLCHAR에 대해 알고 알고 있기 때문에xmlChar * strings 연결

  1. error c2440 initializing cannot convert from const char[6] to const xmlChar *.
  2. A const_cast can only adjust type qualifiers; it cannot change the underlying type.

XMLCHAR는 xmlstring.h, libopc/libxml2를에서 정의된다.

xmlChar * temp = c->part_array[i].name; //this is a filename.doc with path, has no compile error 
       const xmlChar* temp2 = const_cast<xmlChar*>(".rels"); //"rels" here has error 
       xmlStrcat(temp, temp2); 

xmlStrcat 내가 행복하기 TEMP2를 일단 내가 생각 xmlStrcat을 (XMLCHAR * 똥개, const를 XMLCHAR * 추가), 원한다.

아이디어가 있으십니까? 이런 식으로 캐스팅 된 xmlChar * 예제를 찾는 데 문제가 있습니다.

error c2440 initializing cannot convert from const char[6] to const xmlChar*

답변

0

내가 xmlStrndup 및 xmlCharStrndup이

 xmlChar * temp = xmlStrndup(c->part_array[i].name, max_part_name); 
     const char* tempA = ".rels"; 
     xmlChar* temp2 = xmlCharStrndup(tempA, sizeof(tempA)); 
     xmlStrcat(temp, temp2); 
     const xmlChar* temp3 = (const xmlChar*)temp; 
0

직접 캐스팅이 나를 위해 일한 사용하지 감아 :

const xmlChar* temp2 = ".rels"; 

을하지만 오류가 발생합니다 : 난 그냥 사용하여 시도

enter image description here