Hi I have a quick question, I am trying to add strings to a listbox in that is in a dialog window, I can do it if I already define a buffer as char * buf = L"Some Text"; but I am trying to combine serveral things into one string and then add it to the listbox but when I use strcat(buf, (char *)L"Some Text"), I get a access error.
I already tried using the buffer with out the L in front of the quotations but I just get garbage in the listbox when that is done. Here is the code that I have:
Code:
char * buf;
int index;
buf = (char *)malloc(sizeof(char *) * 50);
strcpy(buf, (char*)L"{");
strcat(buf, (char *)L"Something");
strcat(buf, (char *)L"}");
index = SendDlgItemMessage(hwnd, IDC_LIST1, LB_ADDSTRING, (WPARAM)0, (LPARAM)(char*)buf);
SendDlgItemMessage(hwnd, IDC_LIST1, LB_SETITEMDATA, (WPARAM)0, (LPARAM)index);
** So what I am trying to get it to do is add a string to the listbox in the following format: "{ Something }" I just get garbage when I try to enter it as a char *. But when I try to combine L"String" to my format using strcat() I get write access errors it is a constant.
Can anyone help?
Thanks