Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6779351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:22:30+00:00 2026-05-26T16:22:30+00:00

My program simulates a video store. In my list there are multiple copies of

  • 0

My program simulates a video store. In my list there are multiple copies of some videos. If I try to rent a video and the first copy of that video in the list is already rented, my program fails to continue checking to see if the other copies are available (a film is available if custId is ‘0000’). Take a look at the text file from where the list gets its members for a better understanding of what i’m describing:

enter image description here

Could anyone take a look and let me know if they spot an issue? Any help is appreciated, thanks.

Code from main

 try
 {
     int index = 0;
     bool found = false;

     while (!found)
     {
         if (strncmp(filmId,filmList.getAt(index).number,6) == 0 && strncmp("0000",filmList.getAt(index).rent_id,5) == 0)//If that film is rented by NO customer
         {
             found = true;//customer can rent it

             strcpy(newItem.number,filmId);//copy filmId into newItem
             filmList.retrieve(newItem);//copy the struct in our orderedList with the same filmId/copy into newItem
             filmList.remove(newItem);//delete the struct with same filmId/copy as newItem from the orderedList
             strcpy(newItem.rent_id,custId);//update info in
             strcpy(newItem.rent_date,rentDate);//           newItem to show
             strcpy(newItem.return_date,dueDate);//                          that it has been rented
             filmList.insert(newItem);//put NewItem into list, effectivily replacing the removed item.

             cout << "Rent confirmed!" << endl;
         }
         else
         {
             if (strncmp(filmId,filmList.getAt(index).number,6) > 0 || strncmp("0000",filmList.getAt(index).rent_id,5) > 0)
             {
                 ++ index;
             }
             else
             {
                 throw string ("Not in list");
             }
         }
     }
 }
 catch (string s)
 {
     cout << "\n***Failure*** " << s << endl;
 }

Let me know if more code is required from any other parts of the program.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:22:31+00:00Added an answer on May 26, 2026 at 4:22 pm

    Here’s my best guess with the code provided.

    Let’s say we are looking up 101001Casablanca, therefore I’m assuming filmId = “101001Casablanca”. Also, assume the 101001Casablanca is checked out to customer 0001. We are comparing the first 6 characters of filmId to filmList.getAt(index).number, which I’m going to assume is at the very least “101001”. This passes, but since it is checked out the second condition fails.

    In the else we check the same strings in the first condition and still get 0 returned from strncmp which is false. The second condition is also false since strncmp(“0000”, “0001”, 5) is -1. Therefore we go to the final else which throws.

    If you are only checking string equality with strncmp, remember that it can return -1, therefore check if equal or not equal to 0.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

ok, so i got a some what intricate program that simulates the uni systems
I have a program that simulates best-fit memory management. Basically, while there are available
I have a program that simulates mouse click. Code is something like this: [DllImport(user32.dll,
I have a program which draws some terrain and simulates water flowing over it
I have a program which simulates a physical system that changes over time. I
For my data structure class, I am trying to write a program that simulates
I create a program that simulates me browsing to gmail, entering the user name
I have a program that simulates dice rolls and compares them to values in
I'm writing a program that simulates a snake, and the values of each section
I was creating a simple program that simulates a coin toss for my class.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.