Click to See Complete Forum and Search --> : Filling struct with data...


japanfred
February 10th, 2005, 08:20 PM
Hi,

This is my struct and it's enum


enum Length
{
EventType = 2,
LogNumber = 1,
EventSequence = 4,
VarianceCode = 3,
ExactAirTime = 8,
ScheduledTime = 8,
ScheduledTimeMode = 1,
EventDuration = 8,
VideoSource = 12,
VideoEffects = 10,
AudioSource = 12,
AudioEffects = 10,
HouseNumber = 20,
TimeCodeIn = 8,
TimeCodeOut = 8,
FCCSource = 1,
Description = 30,
FacilityDescription = 30,
FCCType = 10,
SecondarySource = 1,
RecordType = 1,
Offset = 5,
NewShowFlag = 1,
SegmentNumber = 2,
Unused = 6
};

struct playlistContents
{
int EventType;
int LogNumber;
int EventSequence;
char VarianceCode[VarianceCode]; // Not Used
char ExactAirTime[ExactAirTime];
char ScheduledTime[ScheduledTime];
char ScheduledTimeMode; // Only 1 byte, either T or White Space
char EventDuration[EventDuration];
char VideoSource[VideoSource];
char VideoEffects[VideoEffects]; // Not Populated (possibly used though)
char AudioSource[AudioSource];
char AudioEffects[AudioEffects]; // Same as Video Effects
char HouseNumber[HouseNumber];
char TimeCodeIn[TimeCodeIn];
char TimeCodeOut[TimeCodeOut];
char FCCSource; //Only 1 bytes Not too sure whats in it, it's either WhiteSpace, or something else.
char Description[Description]; //Title
char FacilityDescription[FacilityDescription];
char FCCType[FCCType];
char SecondarySource; // Either Y or WhiteSpace
char RecordType; //I = Interstitial, P = Programme, S = Commercial.
char Offset[Offset]; //White space in the file. (Not Populated)
char NewShow; //Flag for a New show. If Repeat = No then Flag = Y else Blank.
char SegmentNumber[SegmentNumber]; //Part Number
char Unused[Unused]; // As name states.
};



When i try to fill that struct with data, it comes out totally wrong in the compiler.


playlistContents *pc = new playlistContents;
ZeroMemory(pc, sizeof(playlistContents));

strcpy(pc->VarianceCode, "123");
strcpy(pc->ExactAirTime, "12345678");
strcpy(pc->ScheduledTime, "12345678");

//Breakpoint here to check variables.
delete pc;


when i check to see what the variables contain, it comes out like this! (Check attachment)

I'm not sure if i'm doing anything wrong...and im looking for any help please!

Thanks!

Dean.

japanfred
February 10th, 2005, 08:29 PM
Using Vs 2005...i'll try it with 2003, to see if there are any differences.

And that is all the code i'm using towards that struct.

Paul McKenzie
February 10th, 2005, 08:33 PM
Please don't name your enums the same as your character arrays. Change this and try again

char VarianceCodeData[ VarianceCode + 1]; // Not Used
char ExactAirTimeData[ ExactAirTime + 1];
char ScheduledTimeData [ScheduledTime +1 ];

You are missing the room for the terminating NULL byte.

Regards,

Paul McKenzie

japanfred
February 10th, 2005, 08:36 PM
And now it's fixed..

Top man!

Cheers Paul.