Thread: Some problems in my project

  1. #1
    Registered User
    Join Date
    Oct 2014
    Posts
    33

    Some problems in my project

    I'm to create a personal movie database. And this is due this midnight.
    I haven't been coding for long. It's only been 1-2 months. So, I'm still pretty newbie. My problems are:
    1. I can write the file, but in the file it shows unknown characters.
    2. I can't show the movies in full movie list.
    Here's what I did:

    Code:
    #include<stdio.h>
    struct MOVIES
    {
        int  Movie_Year;
        char Movie_Name[100],Movie_Genre[50],Movie_Language[50],Actor_Name[100];
    
    };
    void MENU();
    void ADD_MOVIE();
    void SEARCH_MOVIE();
    void FULL_MOVIE_LIST();
    void EDIT_MOVIE();
    void EXIT();
    
    int main()
    
    {
        MENU();
    
        return 0;
    }
    
    
    void MENU()
    
    
    {
    
             int SELECT;
    
        do
        {
    
            printf("\nMAIN_MENU:\n");
            printf("\t\t1.ADD MOVIE\n\t\t2.SEARCH MOVIE\n\t\t3.FULL MOVIE LIST\n\t\t4.EDIT MOVIE\n\t\t5.EXIT");
            printf("\n\nSELECT:");
            scanf("%d",&SELECT);
    
            if (SELECT==1)
            {
                ADD_MOVIE();
    
    
    
            }
    
            else if(SELECT==2)
            {
    
                SEARCH_MOVIE();
    
    
            }
            else if(SELECT==3)
    
            {
    
                FULL_MOVIE_LIST();
    
    
            }
    
            else if(SELECT==4)
            {
    
                EDIT_MOVIE();
    
    
            }
    
            else if(SELECT==5)
            {
                system("cls");
                printf("\n\n\n\t\t\t\tGOOD BYE\n\n\n\n\n");
                system("pause");
                system("cls");
            }
    
    
             else
            {
                system("cls");
                printf("\n\n\n\aINVALID INPUT\nPLEASE TRY AGAIN\a\n\n\n\n\n");
    
            }
    
    
    
    
    
        } while(SELECT!=5);
    }
    
    
    
    void ADD_MOVIE()
    
    {
    
    
       struct MOVIES INFO;  //declare a structure variable
    
        FILE *pfile;    //FILE pointer
        pfile=fopen("zero_requiem.txt","ab");
    
        if (pfile!=NULL)
     {
    
      printf("\t\t\tMovie Name\t\t\n\n");
    
      printf("\nENTER Movie Name:");
      fflush(stdin);
      gets(INFO.Movie_Name);
    
      printf("\nENTER Genre:");
      fflush(stdin);
      gets(INFO.Movie_Genre);
    
      printf("\nENTER Language:");
      fflush(stdin);
      gets(INFO.Movie_Language);
    
      printf("\nENTER Actor Name:");
      fflush(stdin);
      gets(INFO.Actor_Name);
    
    
      printf("\nENTER Year:");
      scanf("%d",&INFO.Movie_Year);
      fwrite(&INFO,sizeof(INFO),1,pfile);
    
    
    
    
    
    
     fclose(pfile);
     }
    
     else        //NULL means file not opened successfully
       {
            printf("\nCould not open file\n");
    
    
        }
    
    
    
    system("pause");
    system("cls");
    
    }
    
    
    
    
    
    void SEARCH_MOVIE()
    {
    
    }
    void FULL_MOVIE_LIST()
    {
        struct MOVIES INFO;  //declare a structure variable
    
        FILE *pfile;    //FILE pointer
        pfile=fopen("zero_requiem.txt","rb");
    
        if (pfile!=NULL)
     {
         printf("%.20s%.20s%.20s%.20s%s,Movie Name, Movie Genre, Movie Language, Movie Year, Actor Name");
         {
             fread(&INFO,sizeof(INFO),1,pfile);
             if(!feof(pfile));
         }
    {
        printf("%.20s%.20s%.20s%.20s%s,Movie Name, Movie Genre, Movie Language, Movie Year, Actor Name");
    }while(!feof(pfile));
    }
    
    
    
    }
    void EDIT_MOVIE()
    {
    
    
    
    }
    
    
    
    void EXIT()
    {
    
    
    
    
    }

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    You already requested for help on this here: Adding & Viewing record in c

    *thread closed*
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 08-02-2013, 06:45 PM
  2. Problems with project
    By ghost_rider in forum C++ Programming
    Replies: 5
    Last Post: 11-05-2011, 06:36 AM
  3. Problems With My Project
    By pat3lbr0s2014 in forum C++ Programming
    Replies: 2
    Last Post: 01-09-2010, 06:13 PM
  4. problems in with design of a server project.
    By codec in forum C++ Programming
    Replies: 4
    Last Post: 02-28-2003, 09:11 AM
  5. DJGPP project problems
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 06-08-2002, 07:16 PM