February 10th, 2005, 09:20 PM
#1
Filling struct with data...
Hi,
This is my struct and it's enum
Code:
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.
Code:
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.
Attached Images
February 10th, 2005, 09:29 PM
#2
Re: Filling struct with data...
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.
February 10th, 2005, 09:33 PM
#3
Re: Filling struct with data...
Please don't name your enums the same as your character arrays. Change this and try again
Code:
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
Last edited by Paul McKenzie; February 10th, 2005 at 09:35 PM .
February 10th, 2005, 09:36 PM
#4
Re: Filling struct with data...
And now it's fixed..
Top man!
Cheers Paul.
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width