المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : How to pass array inside Vector in C++



C++ Programming
07-24-2009, 09:30 PM
I am using vector to store the incoming data. Now my data is stored in Struct. I want to store only "bydata[]" from my structure into vector.... as the data keeps coming in.... I will just keep adding at the end of the vector "bydata[]" .....
How do I store this data using vector... or theres any other method tht I can use it.....

#define MAX_DATA_BYTES 60
typedef struct
{
unsigned char CheckFlags;
unsigned char Checksum;
unsigned short SequenceCounter;
} sHeader; //

typedef struct
{
sHeader Header;
unsigned char byData[MAX_DATA_BYTES];
} sData; // sTPPayload


Below code shown previously stores the entire structure... but I just want the "sData.byData[]" to be stored....

#include ;
struct Whatever
{ int x;
};
int Store(Whatever const& w, std::vector& vw)
{
vw.push_back(w);
}

Please can someone help me.....