I have been searching through the forums and found a couple snippets of code and from that i came up with this. What i want to do is search for the specific movie code and then update the movie status from inactive to active (for argument sake). Thanks for any help you can give.
Code:
#include <stdio.h>
#include <stdlib.h>
typedef struct SYSTEM_MOVIE{
int movie_code;
int movie_dur;
char movie_title[25];
char movie_rating[5];
char movie_dir[10];
char movie_status[10];
char movie_genre[10];
}MOVIE;
int main(){
FILE *movie_fp;
movie_fp = fopen("movies.dat", "r+b");
int m_code;
MOVIE movie_data;
printf("*** Welcome to the movie updater! ***\n\n\n");
if(movie_fp != NULL){
printf("Please enter the code of the movie you wish to update: ");
scanf("%d", &m_code);
fseek(movie_fp, sizeof(movie_data)*(m_code - 1), SEEK_SET);
fread(&movie_data, sizeof(movie_data), 1, movie_fp);
fclose(movie_fp);
if (movie_data.movie_code != 0)
{
printf("%d", movie_data.movie_code);
}
else
printf("Record not found");
}
else{
printf("File not found!!!");
}
}