How do you use variables within structures in C++?
I'd like to move the data to a Winform textbox and to USB variables.
Tried several string conversion techniques, but I'm not referring to the structure element properly, I keep getting all sorts of errors.
I'd like to get to the contents that were just copied to FLIGHTDATA.
// Assign data to structure
pObjData = (SIMCONNECT_RECV_SIMOBJECT_DATA*)pData;
if (pData->dwID == SIMCONNECT_RECV_ID_SIMOBJECT_DATA && pObjData->dwRequestID == REQUEST_1)
{
FlightData = (Struct1*)&pObjData->dwData;
This is where FlightData is defined:
struct Struct1
{
public:double RPM_Indicator;
// double ADFMode;
};
//Struct1 LvarList;
SIMCONNECT_RECV_SIMOBJECT_DATA* pObjData = NULL;
SIMCONNECT_RECV* pData = NULL;
DWORD cbData = 0;
Struct1* FlightData = NULL;
bool bDone = false;
It's RPM_Indicator that interests me.
1. What technique do I use to convert it to a string? 2. I'd also like to learn how to truncate decimals.
Thanks!
Robert
SOLUTION:
It helps when you learn how to properly refer to the structure element, and to know how to convert types. Thank you google.
int intEngineRPM = int(FlightData->RPM_Indicator);
this->tbRPM->Text = intEngineRPM.ToString();
Robert :)