crptcblade
Sep 2nd, 2001, 09:23 PM
You're asking the wrong guy if you want a real answer:rolleyes:, but I would imagine that it would be better to declare it outside of the loop, since it is just being used over and over.
for(i=0;i<index;i++)
{
char val[100] = "his";
itoa(i, thei, 20);
strcat(val, thei);
MessageBox(NULL,thei,thei,MB_OK);
//Get the caption of the item based on its index
SendMessage(ch, CB_GETLBTEXT, i, (LPARAM)buffer);
//Add the item to the registry key
RegSetValueEx(regkey, val, 0, REG_SZ, (LPBYTE)buffer, strlen(buffer)+1);
delete [] val; //added
}
I imagine that would be better for memory usage, but don't take my word as fact
:)
for(i=0;i<index;i++)
{
char val[100] = "his";
itoa(i, thei, 20);
strcat(val, thei);
MessageBox(NULL,thei,thei,MB_OK);
//Get the caption of the item based on its index
SendMessage(ch, CB_GETLBTEXT, i, (LPARAM)buffer);
//Add the item to the registry key
RegSetValueEx(regkey, val, 0, REG_SZ, (LPBYTE)buffer, strlen(buffer)+1);
delete [] val; //added
}
I imagine that would be better for memory usage, but don't take my word as fact
:)