Click here to Skip to main content
15,885,842 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Help with threads Pin
AndrewG123113-Sep-12 7:46
AndrewG123113-Sep-12 7:46 
GeneralRe: Help with threads Pin
David Crow13-Sep-12 7:55
David Crow13-Sep-12 7:55 
GeneralRe: Help with threads Pin
AndrewG123113-Sep-12 8:54
AndrewG123113-Sep-12 8:54 
QuestionRe: Help with threads Pin
David Crow13-Sep-12 9:32
David Crow13-Sep-12 9:32 
AnswerRe: Help with threads Pin
AndrewG123127-Sep-12 12:02
AndrewG123127-Sep-12 12:02 
GeneralRe: Help with threads Pin
David Crow28-Sep-12 2:13
David Crow28-Sep-12 2:13 
GeneralRe: Help with threads Pin
Albert Holguin5-Sep-12 12:22
professionalAlbert Holguin5-Sep-12 12:22 
QuestionStructure containing byte[1] as member variable Pin
Rahul from Poona4-Sep-12 8:45
Rahul from Poona4-Sep-12 8:45 
I m reading some data from device whose length I dont know at compile so I made a structure as of following type to store data

struct MessagData
{
DWORD dwSize;
BYTE byData[1];
}


(as far as I know byData[1] declares a byte array of variable length, but I dont know where it allocates memory for the same)
and I m taking a pointer to a variable of this type structure as shown below

MessagData* pMessagData = new MessagData;

suppose data read from device is stored in some variable mentioned below:

char chReadData[100];

after filling the read data which is of variable length i am copying the same data to byData variable of this pointer as shown below:

memcpy(pMessagDat->byData,
chReadData,
pMessagDat->dwSize);


[Length of read data is always less than 100]

upto here it is working fine but when i am trying to do following thing application gave some error of heap corruption even though i m deallocating in the same application in which i have created it.
Please someone help me......
AnswerRe: Structure containing byte[1] as member variable Pin
Chris Losinger4-Sep-12 8:59
professionalChris Losinger4-Sep-12 8:59 
GeneralRe: Structure containing byte[1] as member variable Pin
jschell4-Sep-12 11:32
jschell4-Sep-12 11:32 
GeneralRe: Structure containing byte[1] as member variable Pin
Chris Losinger4-Sep-12 11:42
professionalChris Losinger4-Sep-12 11:42 
GeneralRe: Structure containing byte[1] as member variable Pin
jschell5-Sep-12 11:28
jschell5-Sep-12 11:28 
GeneralRe: Structure containing byte[1] as member variable Pin
Chris Losinger5-Sep-12 11:51
professionalChris Losinger5-Sep-12 11:51 
GeneralRe: Structure containing byte[1] as member variable Pin
jschell6-Sep-12 8:31
jschell6-Sep-12 8:31 
GeneralRe: Structure containing byte[1] as member variable Pin
Chris Losinger6-Sep-12 9:19
professionalChris Losinger6-Sep-12 9:19 
GeneralRe: Structure containing byte[1] as member variable Pin
jschell13-Sep-12 8:07
jschell13-Sep-12 8:07 
GeneralRe: Structure containing byte[1] as member variable Pin
Chris Losinger13-Sep-12 8:11
professionalChris Losinger13-Sep-12 8:11 
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 

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.