![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| SSH doesn't pick up user's project from /etc/project | kurgan | SUN Solaris | 2 | 05-21-2008 12:52 PM |
| Who know this project? | Osawa | UNIX for Dummies Questions & Answers | 5 | 09-09-2007 01:08 AM |
| First Project help | arjunjag | High Level Programming | 6 | 07-16-2007 07:10 AM |
| project | nrusimha | UNIX for Dummies Questions & Answers | 1 | 02-07-2006 07:51 AM |
| GTK+ project | santhosh.linux | Post Here to Contact Site Administrators and Moderators | 0 | 11-16-2005 10:36 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Project Help
hi all.
Im not sure whether this is the correct forum to post in, but here goes. I've been given my first year (uni) project c++, a pretty small one really. Problem is I have written a code, but I havent tested or debugged it (dont ask). Can someone check it and correct any errors I have made, and suggest anyways i can improve it further. Thanks in advanced. ![]() ps. Im not sure whether my program is actually doing the things the scenario wants me to do. I dont know whether Im on the right track so I have attached the scenario to this post, and if anyone could read the scenario and see if my code is the correct way forward etc.. Thanks. #include <iostream> #include <assert> #include <fstream> using namespace std ; const int BOOKS_MAX = 5000 // OPEN/READ/PROCESS BOOKDATA FILE FUCTION void openfile (int argc, char* argv[]) { assert (argc >= 2) ; ifstream accfile(argv[1]); if ( !accfile ) { cerr << "File " << argv[1] << " not found\n" ; exit(1) ; } int books = 0; books a ; accfile >> a.name >> a.booktitle >> a.booktype >> a.ID >> a.Taken ; account accs[BOOKS_MAX] ; int read = 0 //Read data file do { accfile >> accs[read].name >> accs[read].booktitle >> accs[read].booktype >> accs[read].ID ; >> accs[read].Taken if (accfile) { read++ ; } } while (accfile && read < BOOKS_MAX) ; cout << read << " Books read\n " ; accfile.close() ; // Begin proccess for (int i = 0; i < read; i++) { if (accs[i].booktitle == input && accs[i].Taken = 0 { cout << accs.booktitle << "This book is currently unavailable " ; exit (0) ; } else { cout << accs[i].booktitle << "This book is Available " ; } } cout << "To loan this book please press 1, otherwise, to exit press 9\n " ; int issue = 0 ; cin >> issue ; if (issue == 1) { ofstream oaccfile( argv[1] ) ; for (int i = 0; i < read; i++) { oaccfile << accs[i].taken = 0 << endl ; } oaccfile.close(); } else { if (issue == 9) { exit(0); } } // OPEN USERDATA FILE FUNCTION void user (int argc, char* argv[]) { assert (argc >= 2) ; ifstream accfile(argv[1]); if ( !accfile ) { cerr << "File " << argv[1] << " not found\n" ; exit(1) ; } int accounts = 0 ; accounts a; accfile >> a.name >> a.street >> a.ID >> a.Bookstaken ; int USER = 1000 ; account accs[USER] ; int readn = 0 ; //Read data file do { accfile >> accs[readn].name >> accs[readn].street >> accs[readn].ID >> accs[readn].Bookstaken ; if (accfile) { readn++ ; } } while (accfile && read < USER) ; cout << readn << " acccounts read\n " ; accfile.close() ; // Input int main() { cout << "Welcome\n " << "Please choose from one of the following options\n " << "To Search for a book press 1\n To Return a book press 2\n To exit Press 3 " int a = 0 ; cin >> a ; if (cin == 0) { exit(0); } else { if (cin = 1) { cout << "Please enter a book title " ; cin >> input ; openfile (input) ; exit(0) ; } else ( if (cin = 2) { //WRITE CODE HERE FOR BOOK RETURN } } |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|