Monday, January 30, 2012

What is wrong with this program?

it doesnt Write into the file named MOVIE.DAT WHY?





#include%26lt;iostream.h%26gt;

#include%26lt;conio.h%26gt;

#include%26lt;stdio.h%26gt;

#include%26lt;fstream.h%26gt;



class Database



{

char Mname[30];

char Director[30];

char Writer[30];

char Cast[30];

char Tagline[50];

char DVD[10];

char Country[20];

char Genre[15];

char Language[15];

char cast[20];

int Grossing;

int Budget;

float CRating;

float URating;

int Release;



public:

void input();

void output();



};



void Database :: input()

{

cout %26lt;%26lt; endl %26lt;%26lt; "Enter Movie Name : ";

gets(Mname);

cout %26lt;%26lt; endl %26lt;%26lt; "Enter Movie Director : ";

gets(Director);

cout %26lt;%26lt; endl %26lt;%26lt; "Enter Movie Writer : ";

gets(Writer);

cout %26lt;%26lt; endl %26lt;%26lt; "Enter Main Cast : ";

gets(cast);

cout %26lt;%26lt; endl %26lt;%26lt; "Enter Movie Tagline : ";

gets(Tagline);

cout %26lt;%26lt; "Enter DVD[OUT NOW/COMING SOON/NOT AVAILABLE] : ";

gets(DVD);

cout %26lt;%26lt; endl %26lt;%26lt; "Enter Movie WorldWide Grossings ($) : ";

cin %26gt;%26gt; Grossing;

cout %26lt;%26lt; endl %26lt;%26lt; "Enter Movie Budget : ";

cin %26gt;%26gt; Budget;

cout %26lt;%26lt; endl %26lt;%26lt; "Enter Movie Critics RATING : ";

cin %26gt;%26gt; CRating;

cout %26lt;%26lt; endl %26lt;%26lt; "Enter Movie User RATING : ";

cin %26gt;%26gt; URating;

cout %26lt;%26lt; "Enter Movie YEAR of Release : ";

cin %26gt;%26gt; Release;

cout %26lt;%26lt; endl %26lt;%26lt; "Entry Movie Country: ";

gets(Country);

cout %26lt;%26lt; endl %26lt;%26lt; "Enter Language(s) : ";

gets(Language);

cout %26lt;%26lt; endl %26lt;%26lt; "Enter Movie Genre : ";

cin %26gt;%26gt; Genre;

}



void Database :: output()

{

cout %26lt;%26lt; endl %26lt;%26lt; endl %26lt;%26lt; " ";

puts(Mname);

cout %26lt;%26lt; endl %26lt;%26lt; endl %26lt;%26lt; endl %26lt;%26lt; "Director: ";

puts(Director);

cout %26lt;%26lt; endl %26lt;%26lt; "Writer: ";

puts(Writer);

cout %26lt;%26lt; endl %26lt;%26lt; "Main Cast: ";

puts(cast);

cout %26lt;%26lt; endl %26lt;%26lt; "Tagline: ";

puts(Tagline);

cout %26lt;%26lt; "DVD :";

puts(DVD);

cout %26lt;%26lt; "Genre : ";

puts(Genre);

cout %26lt;%26lt; "Language : ";

puts(Language);

cout %26lt;%26lt; "Country : ";

puts(Country);

cout %26lt;%26lt; endl %26lt;%26lt; "Worldwide Grossing: " %26lt;%26lt; Grossing;

cout %26lt;%26lt; endl %26lt;%26lt; "Movie Budget: " %26lt;%26lt; Budget;

cout %26lt;%26lt; endl %26lt;%26lt; "Critics Rating: " %26lt;%26lt; CRating;

cout %26lt;%26lt; endl %26lt;%26lt; "User Rating: " %26lt;%26lt; URating;

cout %26lt;%26lt; endl %26lt;%26lt; "RELEASE DATE: " %26lt;%26lt; Release;



}







void main()

{

clrscr();

int i=0,ch;

char Y;

fstream Min;

Database Mov[10],Movieadd[10];

cout %26lt;%26lt; "Welcome to Movie Library";

cout %26lt;%26lt; endl %26lt;%26lt; endl %26lt;%26lt; endl %26lt;%26lt; endl %26lt;%26lt; "Enter Choice "

%26lt;%26lt; endl %26lt;%26lt; "(1.) Enter a new Movie in the Movie DATABASE"

%26lt;%26lt; endl %26lt;%26lt; "(2.) Search Movie By Genre"

%26lt;%26lt; endl %26lt;%26lt; "(3.) Enter Movie Name to Search Database "

%26lt;%26lt; endl %26lt;%26lt; endl %26lt;%26lt; " ";

cin %26gt;%26gt; ch;

switch(ch)

{

case 1:

Min.open("Movie.dat",ios::out || ios::in || ios::app || ios::binary);

Mov[i].input();

Min.write((char*)%26amp;Mov[0],sizeof(Mov[0]鈥?br>
cout %26lt;%26lt; endl %26lt;%26lt; endl %26lt;%26lt; "Want to see Enterered Movie : ";

cin %26gt;%26gt; Y;

if(Y=='Y' || Y=='y')

{

Min.read((char*)%26amp;Mov[0],sizeof(Mov[0])鈥?br>
Mov[0].output();

Min.close();

}

else

{Min.close();}

i++;

break;

}

getch();

}What is wrong with this program?
I know this isn't helpful at all.

But i can't see any errors?
  • traffic cameras
  • duplicolor
  • No comments:

    Post a Comment