Code:
void EditBoxFileParser(HDC hdc, PAINTSTRUCT* ps, HFONT hFont, HWND hwnd, HWND hEdit)
{
int iCount;
WORD iLength, iOffset;
TCHAR **Lines;
//Get Number of Lines in Edit Field
iCount = SendMessage(hEdit, EM_GETLINECOUNT, 0, 0);
//If Editbox is empty, exit function
if(!iCount)
return;
Lines = new TCHAR*[iCount];
//Populate 2D array, Lines[LineIndex][LineText]
for(int i=0; i<iCount; i++)
{ iOffset = SendMessage(hEdit, EM_LINEINDEX, i, 0);
iLength = (WORD)SendMessage(hEdit, EM_LINELENGTH, iOffset, 0);
Lines[i] = new TCHAR[iLength+sizeof(WORD)+1];
CopyMemory(Lines[i], &iLength, sizeof(WORD));
SendMessage(hEdit, EM_GETLINE, i, (LPARAM)Lines[i]);
Lines[i][iLength] = '\0';
}
//Visually Verify Lines[][]
for(int i=0, x=300, y=275; i<iCount; i++)
TextOut(hdc, x, y+=20, Lines[i], lstrlen(Lines[i]));
//Parse User Entered Text
TCHAR **Name = new TCHAR*[iCount];
TCHAR **FiberCount1 = new TCHAR*[iCount];
TCHAR **FiberCount2 = new TCHAR*[iCount];;
int size, word_index;
bool cont = true;
for(int i=0, j=0; i<iCount; i++, j=0)
{
word_index = 0;
cont = true;
do{
//Extract Fiber Name
while(Lines[i][j]!=',')
{
j++;
}
Lines[i][j]='\0';
Name[i] = new TCHAR[j-word_index+1];
lstrcpy(Name[i], Lines[i][word_index]);
Name[i][j-word_index] = '\0';
word_index = j;
word_index++;
//Extract Beginning Fiber Count
while(Lines[i][j]!='-')
{
j++;
}
Lines[i][j] = '\0';
FiberCount1[i] = new TCHAR[j-word_index+1];
lstrcpy(FiberCount1[i], Lines[i][word_index]);
FiberCount1[i][j-word_index] = '\0';
word_index = j;
word_index++;
//Extract Ending Fiber Count
while(Lines[i][j]!=',' || Lines[i][j]!='\0')
{
j++;
}
if(Lines[i][j]=='\0')
cont = false:
Lines[i][j] = '\0';
FiberCount2[i] = new TCHAR[j-word_index+1];
lstrcpy(FiberCount2[i], Lines[i][word_index]);
FiberCount2[i][j-word_index] = '\0';
}while(Lines[i][j]!='\0' && cont == true);
}
//Visually Verify Lines[][]
for(int i=0, x=400, y=275; i<iCount; i++)
TextOut(hdc, x, y+=20, Name[i], lstrlen(Lines[i]));
}
to me.. this seems like a simple operation.. pass in the cstring to be copied.. pass in a pointer to a source buffer.. null termination takes care of the rest.. but why do I get these compiler errors..??!