PDA

Click to See Complete Forum and Search --> : data types in structures


MPrestonf12
Mar 18th, 2001, 12:36 PM
In a function I call I use the structure SYSTEM_POWER_STATUS. Under that stucture each different piece of information has a different data type. When I go to call it once it recieved the data it says im trying to pass a byte to argument two of MessageBox which lacks a cast. Here is a example. ACLineStatus is a byte in the structure.


int getsysdata()
{
SYSTEM_POWER_STATUS sysdata;

GetSystemPowerStatus(&sysdata);

MessageBox(NULL,sysdata.ACLineStatus, "System Data", MB_OK);

return 0;
}


thanks for your help

HarryW
Mar 18th, 2001, 01:03 PM
The MessageBox function is expecting a string. You need to make a string using the itoa() function or something similar, and pass that instead.

Mar 18th, 2001, 05:25 PM
char buf[20];
char* szText = itoa(sysdata.ACLineStatus, buf, 20);
MessageBox(NULL, szText, "System Data", MB_OK);

MPrestonf12
Mar 18th, 2001, 07:10 PM
thanks guys