M
manochavishal
Hi,
I have a structure
MAX_ID is 5
/**Structure for Copies*/
typedef struct NodeVideoCopy * NodeVideoCopyPtr ;
typedef struct NodeVideoCopy
{
char CopyID[MAX_ID];
char type;
char status;
NodeVideoCopyPtr next;
}NodeVideoCopy;
/**Structure for Videos*/
typedef struct NodeVideo * NodeVideoPtr;
typedef struct NodeVideo
{
char * videoname;
char VideoID[MAX_ID];
int Release;
char * director;
unsigned int NoOfCopies;
NodeVideoCopyPtr copies;
NodeVideoPtr next;
}NodeVideo;
/*Display Videos*/
void DisplayVideos(Library * Lib)
{
NodeVideoPtr current;
NodeVideoCopyPtr copy;
current = Lib->VideoList;
while(current!=NULL)
{
printf("\nVideo Name :%s",current->videoname);
copy = current->copies;
printf("\nCopies are :\n");
while(copy!=NULL)
{
printf("\nCopy ID :%s",copy->CopyID); /*Prinitng copies of Video*/
printf("\tCopy type :%c",copy->type);
printf("\tCopy Status :%c",copy->status);
copy = copy->next;
}
current = current->next;
}
}
Now when i am printing copies of a Video
its printing CopyID+type+status together.
Why is this behaviour??
Output is like
Video Name :Jurassic Par‼
Copies are :
Copy ID :C1012SA Copy type :S Copy Status :A
Copy ID :C1013SU Copy type :S Copy Status :U
Video Name :Sholay
Copies are :
Copy ID :C0001SU Copy type :S Copy Status :U
Video Name :CockTail
Copies are :
Copy ID :C0005RU Copy type :R Copy Status :U
Copy ID :C0003RU Copy type :R Copy Status :U
Can't Underatsnd why is it going beyond the alloctaed memory i.e. 5 to
it.
I have a structure
MAX_ID is 5
/**Structure for Copies*/
typedef struct NodeVideoCopy * NodeVideoCopyPtr ;
typedef struct NodeVideoCopy
{
char CopyID[MAX_ID];
char type;
char status;
NodeVideoCopyPtr next;
}NodeVideoCopy;
/**Structure for Videos*/
typedef struct NodeVideo * NodeVideoPtr;
typedef struct NodeVideo
{
char * videoname;
char VideoID[MAX_ID];
int Release;
char * director;
unsigned int NoOfCopies;
NodeVideoCopyPtr copies;
NodeVideoPtr next;
}NodeVideo;
/*Display Videos*/
void DisplayVideos(Library * Lib)
{
NodeVideoPtr current;
NodeVideoCopyPtr copy;
current = Lib->VideoList;
while(current!=NULL)
{
printf("\nVideo Name :%s",current->videoname);
copy = current->copies;
printf("\nCopies are :\n");
while(copy!=NULL)
{
printf("\nCopy ID :%s",copy->CopyID); /*Prinitng copies of Video*/
printf("\tCopy type :%c",copy->type);
printf("\tCopy Status :%c",copy->status);
copy = copy->next;
}
current = current->next;
}
}
Now when i am printing copies of a Video
its printing CopyID+type+status together.
Why is this behaviour??
Output is like
Video Name :Jurassic Par‼
Copies are :
Copy ID :C1012SA Copy type :S Copy Status :A
Copy ID :C1013SU Copy type :S Copy Status :U
Video Name :Sholay
Copies are :
Copy ID :C0001SU Copy type :S Copy Status :U
Video Name :CockTail
Copies are :
Copy ID :C0005RU Copy type :R Copy Status :U
Copy ID :C0003RU Copy type :R Copy Status :U
Can't Underatsnd why is it going beyond the alloctaed memory i.e. 5 to
it.