Click here to Skip to main content
15,891,657 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Structure containing byte[1] as member variable Pin
jschell14-Sep-12 8:41
jschell14-Sep-12 8:41 
GeneralRe: Structure containing byte[1] as member variable Pin
Stefan_Lang5-Sep-12 1:57
Stefan_Lang5-Sep-12 1:57 
GeneralRe: Structure containing byte[1] as member variable Pin
jschell5-Sep-12 11:26
jschell5-Sep-12 11:26 
GeneralRe: Structure containing byte[1] as member variable Pin
Stefan_Lang6-Sep-12 2:53
Stefan_Lang6-Sep-12 2:53 
GeneralRe: Structure containing byte[1] as member variable Pin
jschell6-Sep-12 8:28
jschell6-Sep-12 8:28 
AnswerRe: Structure containing byte[1] as member variable Pin
Richard MacCutchan4-Sep-12 9:07
mveRichard MacCutchan4-Sep-12 9:07 
GeneralRe: Structure containing byte[1] as member variable Pin
Rahul from Poona4-Sep-12 20:00
Rahul from Poona4-Sep-12 20:00 
GeneralRe: Structure containing byte[1] as member variable Pin
Richard MacCutchan4-Sep-12 21:46
mveRichard MacCutchan4-Sep-12 21:46 
Rahul from Poona wrote:
So following line is not applicable here
I had mis-read your question, and assumed that the data was presented in that format. In your original question you do not specify how you get the value of dwSize, but assuming you have some way of finding it then you need to do something like:
C++
struct MessagData
{
    DWORD dwSize;
    BYTE byData[1];
}
char chReadData[100];
int dwNumberRead;
// fill chReadData with the information from external source
// and set dwNumberRead to the length of the data

// now allocate a structure that is big enough to hold this data
// copy the data into the structure and set its length member variable
MessagData* pMessagData = (MessagData*)new BYTE[sizeof(MessagData) + dwNumberRead];
memcpy(pMessagData->byData, chReadData, dwNumberRead);
pMessagData->dwSize = dwNumberRead;

[edit]Added quick and dirty cast[/edit]


BTW please use the code block and var buttons above to add the correct HTML tags, <pre> or <code> to your code rather than making it bold, as I have done here.
One of these days I'm going to think of a really clever signature.

AnswerRe: Structure containing byte[1] as member variable Pin
jschell4-Sep-12 11:46
jschell4-Sep-12 11:46 
QuestionFinding crash information using the MAP file in vs2005 Pin
neha_soni4-Sep-12 1:10
neha_soni4-Sep-12 1:10 
AnswerRe: Finding crash information using the MAP file in vs2005 Pin
David Crow4-Sep-12 2:35
David Crow4-Sep-12 2:35 
AnswerRe: Finding crash information using the MAP file in vs2005 Pin
krmed4-Sep-12 3:33
krmed4-Sep-12 3:33 
AnswerRe: Finding crash information using the MAP file in vs2005 Pin
Stephen Hewitt6-Sep-12 21:46
Stephen Hewitt6-Sep-12 21:46 
Question(SOLVED) make single executable file in vs2008 (MFC) Pin
jawadali4773-Sep-12 1:26
jawadali4773-Sep-12 1:26 
AnswerRe: make single executable file in vs2008 (MFC) Pin
pasztorpisti3-Sep-12 2:05
pasztorpisti3-Sep-12 2:05 
GeneralRe: make single executable file in vs2008 (MFC) Pin
jawadali4774-Sep-12 17:42
jawadali4774-Sep-12 17:42 
GeneralRe: make single executable file in vs2008 (MFC) Pin
pasztorpisti4-Sep-12 23:04
pasztorpisti4-Sep-12 23:04 
GeneralRe: make single executable file in vs2008 (MFC) Pin
jawadali4779-Sep-12 17:45
jawadali4779-Sep-12 17:45 
GeneralRe: make single executable file in vs2008 (MFC) Pin
pasztorpisti9-Sep-12 21:26
pasztorpisti9-Sep-12 21:26 
GeneralRe: make single executable file in vs2008 (MFC) Pin
jawadali47710-Sep-12 17:17
jawadali47710-Sep-12 17:17 
AnswerRe: make single executable file in vs2008 (MFC) Pin
Stephen Hewitt3-Sep-12 16:51
Stephen Hewitt3-Sep-12 16:51 
AnswerRe: make single executable file in vs2008 (MFC) Pin
Richard MacCutchan3-Sep-12 22:22
mveRichard MacCutchan3-Sep-12 22:22 
GeneralRe: make single executable file in vs2008 (MFC) Pin
pasztorpisti4-Sep-12 1:29
pasztorpisti4-Sep-12 1:29 
GeneralRe: make single executable file in vs2008 (MFC) Pin
Richard MacCutchan4-Sep-12 5:42
mveRichard MacCutchan4-Sep-12 5:42 
AnswerRe: (SOLVED) make single executable file in vs2008 (MFC) Pin
Member 103867337-Nov-13 5:00
Member 103867337-Nov-13 5:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.