edvinson
asked on
String Concat problem, not working
I am trying to concat 9 edit controls. I don't see why this code is not working. Can anyone help me get this working?
Thanks!
char szCombo1[2], szCombo2[2],szCombo3[2],
szCombo4[2],szCombo5[2],szCombo6[2],
szCombo7[2],szCombo8[2],szCombo9[2];
GetDlgItemText(gl_hWnd, IDC_COMBO1, szCombo1, strlen(szCombo1));
GetDlgItemText(gl_hWnd, IDC_COMBO2, szCombo2, strlen(szCombo2));
GetDlgItemText(gl_hWnd, IDC_COMBO3, szCombo3, strlen(szCombo3));
GetDlgItemText(gl_hWnd, IDC_COMBO4, szCombo4, strlen(szCombo4));
GetDlgItemText(gl_hWnd, IDC_COMBO5, szCombo5, strlen(szCombo5));
GetDlgItemText(gl_hWnd, IDC_COMBO6, szCombo6, strlen(szCombo6));
GetDlgItemText(gl_hWnd, IDC_COMBO7, szCombo7, strlen(szCombo7));
GetDlgItemText(gl_hWnd, IDC_COMBO8, szCombo8, strlen(szCombo8));
GetDlgItemText(gl_hWnd, IDC_COMBO9, szCombo9, strlen(szCombo9));
std::string strCombo1(szCombo1);
std::string strCombo2(szCombo2);
std::string strCombo3(szCombo3);
std::string strCombo4(szCombo4);
std::string strCombo5(szCombo5);
std::string strCombo6(szCombo6);
std::string strCombo7(szCombo7);
std::string strCombo8(szCombo8);
std::string strCombo9(szCombo9);
std:string strUserCombo;
strUserCombo = strCombo1+strCombo2+strCombo3+strCombo4+strCombo5+strCombo6+strCombo7+strCombo8+strCombo9;
MessageBox(NULL,strUserCombo.c_str(),"DEBUG",NULL);
Thanks!
In the above, 'strlen()' will return 0 or an undefined value, that's why that won't work. You need to provide the actual size of the buffer as the last argument. Are you sure that should be two bytes?
ASKER
I am not sure it should be two bytes, I am expecting the user to enter two digits, thats why i chose 2 bytes. should I only use 1? Or something different? What if I dont know how many characters they entered?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.