Jump to content
The simFlight Network Forums

Read a string with the C++ SDK


Recommended Posts

Hi Pete,

I'm not a C++ expert, and I have some difficulties for reading a string (offset 0x3500 ATC aircraft model). I cannot find any example on reading an FSUIPC string, like it exists for DWORD values in SDK documentation.

Tanks in advance for Help.

Link to comment
Share on other sites

I'm not a C++ expert, and I have some difficulties for reading a string (offset 0x3500 ATC aircraft model). I cannot find any example on reading an FSUIPC string, like it exists for DWORD values in SDK documentation.

A string is merely an array of bytes. Declare a variable large enough, then read the correct number of bytes directly into it. Whilst there are 2 bytes in a WORD and 4 in a DWORD, and 8 in a double, there are almost any number of bytes in a string -- the offset list will tell you the maximum. The address you supply for the FSUIPC read will need to be the byte address of the first byte of the byte array into which you read the string. For example, if you define:

char szATCmodel[24];

DWORD dwResult;

then the FSUIPC_Read could be

FSUIPC_Read(0x3500, 24, (BYTE *) &szATCmodel[0], &dwResult);

or, because C/C++ takes the name of an array as the address of its first element:

FSUIPC_Read(0x3500, 24, (BYTE *) szATCmodel, &dwResult);

I only cast the address by "(BYTE *)" to stop the compiler giving warnings if you are using signed characters instead of unsigned ones ("BYTE" is defined as an unsigned character).

Regards

Pete

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.