Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

i created a library managment system but it would just skip the steps and run all the way down

i created a library manangment system with various switch cases and loops and breaks statements however sometimes it works absolutely fie however sometimes it runs the commands and follows all the statement after that particular switch statement
my code is as undergiven
https://onlinegdb.com/aYdKFJSTy

i tired researching on various sites and with my collegues but no one was able to fnd the solution as we all are new to c and are in early learning phase

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

ok so firstly, you should stop posting a complete 900 lines of code and just give a snippet code of the part which you think is giving problem.
Secondly, the places in where you are facing problem, you have missed the break statement at several places in the switch cases. When you do not put break statement in a switch case the case is executed and then all the cases after it are executed sequentially . you can either use break / exit/ continue statements depending upon your requirement.
For example the switch case in the 687th line of your code does not contain any break statement. Hence, all the statements after the case chosen will be executed and an undesirable output will be displayed .

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading