Filling up a TCHAR* array [c++, win32api]

Hello,

I've been googling for quite a while now and I just can't find anything about filling up a TCHAR* array with data from a vector<string>.
I'm using two comboboxes in winapi.

Function made for filling up the combobox.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//paint.GetTreatmentVector returns a vector<string> with the needed data.

bool FillTreatments(HWND box)
{
	if (paint.GetTreatmentVector().empty()) //ignore this
	{
		TCHAR* pVarName[] = {"Empty", "Empty"};
		SendMessage(box, CB_ADDSTRING, 0, (LPARAM)pVarName[0]);
		SendMessage(box, CB_ADDSTRING, 0, (LPARAM)pVarName[1]);
		return FALSE;
	} //ignore this

	short i = 0; //some counter (not sure if needed in here)
	std::vector<std::string> TreatmentList = paint.GetTreatmentVector(); //put all data from other class into a list.
	for (std::vector<std::string>::iterator it = TreatmentList.begin(); it != TreatmentList.end(); ++it)//access vector with iterator
	{
		std::string temp = (*it); //save contents in a string
		//The following line doesn't work.
		TCHAR* pVarName[i] += {temp.c_str()}; //I'm trying to fill up the TCHAR* array with a string.
		//Errors are written below the post.
		SendMessage(box, CB_ADDSTRING, 0, (LPARAM)pVarName[i]);
		i++;//count
	}
	return TRUE;
}

Errors
error C2057: expected constant expression
error C2466: cannot allocate an array of constant size 0
error C2143: syntax error : missing ';' before '+='
error C2133: 'pVarName' : unknown size
error C2143: syntax error : missing ';' before '{'
error C2143: syntax error : missing ';' before '}'


I wasn't sure if I should've put it in Beginners or here.

~ Rii
TCHAR means either char or wchar_t, depending on whether UNICODE is defined or not.
You could replace all occurences of std::string with std::basic_string<TCHAR> and declaring string literals enclosed in _T() macro to make your code compile no matter UNICODE is defined or not.
I managed to solve it somehow, thanks for your help!
Topic archived. No new replies allowed.