Like Tree1Likes

DVD rental application.

This is a discussion on DVD rental application. within the C++ Programming forums, part of the General Programming Boards category; File i/o in C++ is quite similar to file i/o in C, the one of the differences is that in ...

  1. #16
    Registered User
    Join Date
    May 2010
    Posts
    2,674
    File i/o in C++ is quite similar to file i/o in C, the one of the differences is that in C++ you use file streams instead of FILE*. You may want to study this link for Basic file Input and Output in C++. It should help explain basic C++ file input and output.


    Jim

  2. #17
    Registered User
    Join Date
    Jan 2012
    Posts
    29
    You say I should do this line by line or I misunderstood?

  3. #18
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,406
    Quote Originally Posted by blunt View Post
    Thanks for help! There are also few good ideas that I could use BUT:
    first of all I'd like it to be fully-working program. For now I have two classes: movie and customer. I can add and delete objects, You can get more information about movie or customer. To get it done I need at least 2 things: an idea of renting process and writing (and reading) results of my work into the txt file.

    1. My idea: add to a class customer, let's say 3 strings named 'title1, title2, title3'. And when when You rent a movie, title goes there. But sounds silly to me.

    2. C++ is supposed to be simpler than C but I cannot figure it. In C I opened a file with fopen, read it few lines later, close it with fclose, and write it all down with fwrite just before fclose is executed. I just can't figure it out in C++.

    I dunno if c++ is simpler than c mate haha, but i know where you are coming from, - have a look at the faq pages, you will find information and easy examples of file input and output using c++ also if
    you go to cplusplus website you can enter 'ifstream' or 'ofstream' into the search and you will get good reference material.

    Renting process you need to think about what happens in real life when you rent a movie - if you are not considering the money part and just looking at whether or not your movie is rented then you could just use a boolean member of each movie to say 'isRented' true or false etc. Alternatively you could assign a numberofcopies variable if your shop has more than one of each film - then ++ or -- it when a rental is made.

    For the file i/o what exactly is your aim? Do you want to open a file at runtime and read in all the movie information? When you write to a file do you want to be able to add new movies to the catalogue? Do you want to write a history of rentals made and be able to load that on program open?

    here is another cboard link with general c++ io instruction - part way down you will see a file write example - bear in mind the example appends to the file in the snippet.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  4. #19
    Registered User
    Join Date
    Jan 2012
    Posts
    29
    Quote Originally Posted by rogster001 View Post
    For the file i/o what exactly is your aim? Do you want to open a file at runtime and read in all the movie information? When you write to a file do you want to be able to add new movies to the catalogue?
    That's pretty much what I want. I need to create my own base with this program, I need to edit this information and in the end, before I go out of the program I want it to be saved (not during adding/deleting objects). Let's put it this way:

    Open a program (opening a reading is being done) -> editions, editions, blah blah -> close a program (writing is executed) -> Open a program and so on...

    Oh and I forgot: problem with your references, and ALL references is that they involve easy examples like 'how to put a sentence into a file'. I'm standing here in front of a more complex problem, that non of sites (or books) about C++ can explain...
    Last edited by blunt; 09-19-2012 at 06:27 AM.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Car Rental Program
    By iamtazb in forum C Programming
    Replies: 4
    Last Post: 06-18-2012, 05:05 PM
  2. Replies: 2
    Last Post: 05-18-2012, 04:20 AM
  3. Help - Car Rite Rental (extra credit)
    By mmourot in forum C++ Programming
    Replies: 5
    Last Post: 10-13-2011, 07:00 AM
  4. Replies: 1
    Last Post: 07-03-2010, 01:18 PM
  5. Convirt my C program to a GUI application/Web Application
    By kapil1089thekin in forum C Programming
    Replies: 6
    Last Post: 07-21-2008, 01:43 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21