CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2003
    Posts
    93

    Post 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 Attached Images
    OutputDebugString(...); Is your friend!
    http://www.spikedsoftware.co.uk

  2. #2
    Join Date
    Apr 2003
    Posts
    93

    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.
    OutputDebugString(...); Is your friend!
    http://www.spikedsoftware.co.uk

  3. #3
    Join Date
    Apr 1999
    Posts
    27,449

    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.

  4. #4
    Join Date
    Apr 2003
    Posts
    93

    Re: Filling struct with data...

    And now it's fixed..

    Top man!

    Cheers Paul.
    OutputDebugString(...); Is your friend!
    http://www.spikedsoftware.co.uk

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured