|
-
April 15th, 2008, 11:07 PM
#1
Problem hex string to char * ..
I want to transform hex string I type in Edit Box (MFC) to a char *
like...
aa bb cc dd ee ff 03 f8 d3 fe
typed that in Edit Box and when I press convert button
It should make that into char array well yah char * same thing.
This is what I got so far but for some reason yes it compiles great but when I press convert it crashes
char strData[255] = {0};//held from Edit Box.
char * intercept = NULL;
LRESULT res;
res = SendMessage(GetDlgItem(hDlg,IDC_EDIT),WM_GETTEXTLENGTH,0,0);
if(((int)res == 0 || (int)res > 999))// we want text but not bigger than limit.
{
return 0;
}
SendMessage(GetDlgItem(hDlg,IDC_EDIT),WM_GETTEXT,sizeof(strData),(LPARAM)strData);
char* temp=strdup(strData);
//Convert a hexyString to a hex character and put in array
for(int i = 0; i < res; i++)
intercept[i] = strtoul(temp, &temp, 0x10);
delete[] temp;
temp = 0;
yah.. thats about it
well I know I ain't that smart to figure this out so if anyone could help I'd really like that
Last edited by Fuji22; April 15th, 2008 at 11:10 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|