>printf("Enter the catagory of video you would like displayed(Kids,Action,Romance,Thriller) - ");
>fflush(stdin);
>scanf("%s", Selection);
>fflush(stdin);
This is really not a good idea. Using fflush on input streams results in undefined behavior. If you want to get rid of floating characters after calls to scanf replace fflush ( stdin ); with
while ( getchar() != '\n' );
every time you use scanf to read string data. You could avoid this problem altogether by using fgets when reading string data and scanf only when reading numeric data.
>if (0 != (strstr(((VideoData[j].videotitle)[j])=VideoData[j].videotitle, Selection)))
This is just plain ugly, if your structure is formatted with any sanity at all then you should simply be able to do something like this:
Code:
/* Add an enum to make the mode easier to understand
*/
enum {CATEGORY, TITLE, and so on };
/* Use a switch to dermine how to test the struct
*/
switch ( modeSelection ) {
case CATEGORY:
if ( strcmp ( VideoData[j].category, Selection ) == 0 )
PrintOne ( VideoData[j], modeSelection );
break;
.
.
}
/* The definition of PrintOne would look something like this.
** Using another switch to determine what to print.
*/
void PrintOne ( struct Video *vid, int mode )
{
switch ( mode ) {
case CATEGORY:
/* Print the category details */
case TITLE:
/* Print the title details */
.
.
}
}
-Prelude