case IDC_ADD:
{
//1. получаем данные из поля IDC_EDIT_ADD:
char buf[MAX];
memset(buf, 0, MAX);
GetDlgItemTextA(hwnd, IDC_EDIT_ADD, buf, MAX);
if (CheckData(buf)) {
//2. Добавляем в БД buf:
obj.AddData(buf);
string s = regex_replace(buf, regex("
(\\w+);.\\d+"), string("$1"));
//3. добавляем строку в список:
SendDlgItemMessage(hwnd, IDC_LIST, LB_ADDSTRING, 0,
(LPARAM)s.c_str());
//4. очищаем само поле:
SetDlgItemText(hwnd, IDC_EDIT_ADD, L"");
}
else
MessageBox(NULL, L"Данные должны быть ввида
[Футболист;ЗП]", L"Неверный формат ввода", MB_OK |
MB_ICONINFORMATION);
return TRUE;
}
I want to save text in txt file. I enter "something" in edit control and click IDC_ADD, then I debug code and char array buf has \0 after each element. I think it is cause why "something" is not saved.