473,320 Members | 2,107 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Pointers & arrays in Structures

In some C++ code the follwoing two structures
are existing

typedef struct _STD_DB_TRAILER
{
WORD wSpare1;
DWORD dwSpare1;
char sSpare1[60];
} STD_DB_TRAILER;

typedef struct _WP_BLOB
{
unsigned int size;
char * data;
}WP_BLOB;

These are intialized and the data is serialized into a
blob in the database

Now in my C# project i need to read the blob from database
and de-serialize them to their respective structures
and retrieve data from individual elements

I tried something like this which obviously did not work
private struct STD_DB_TRAILER
{
System.UInt16 wSpare1;
System.UInt32 dwSpare1;
char[] strSpare1; //actually the size had to fixed to 60
}

public struct WP_BLOB
{
public System.UInt32 size;
public System.Char[] uChars; //I need to have a char*
}

how do i do this any suggestions ?
thanks


Nov 15 '05 #1
1 1113
You could try serializing the structure using the BinaryFormatter class.
"vatsa" <an*******@discussions.microsoft.com> wrote in message
news:07****************************@phx.gbl...
In some C++ code the follwoing two structures
are existing

typedef struct _STD_DB_TRAILER
{
WORD wSpare1;
DWORD dwSpare1;
char sSpare1[60];
} STD_DB_TRAILER;

typedef struct _WP_BLOB
{
unsigned int size;
char * data;
}WP_BLOB;

These are intialized and the data is serialized into a
blob in the database

Now in my C# project i need to read the blob from database
and de-serialize them to their respective structures
and retrieve data from individual elements

I tried something like this which obviously did not work
private struct STD_DB_TRAILER
{
System.UInt16 wSpare1;
System.UInt32 dwSpare1;
char[] strSpare1; //actually the size had to fixed to 60
}

public struct WP_BLOB
{
public System.UInt32 size;
public System.Char[] uChars; //I need to have a char*
}

how do i do this any suggestions ?
thanks

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Konstantin Shemyak | last post by:
I have a big structure tree. All leaves are scalar values (no pointers). Present are arrays, structures and unions. I want to be able to store/read the content of the structure in/from a file, and...
7
by: Frank M. | last post by:
I'm trying to declare an array of pointers to structures so that I can make the last element a NULL pointer. I figure that it would more easily allow my library routines to know when to stop...
5
by: Paminu | last post by:
Why make an array of pointers to structs, when it is possible to just make an array of structs? I have this struct: struct test { int a; int b;
62
by: onkar | last post by:
Why use pointers at all??
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.