The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-17-2005
Shade Shade is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 1
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
}
}
Attached Files
File Type: doc scenario.doc (5.0 KB, 6 views)
  #2 (permalink)  
Old 12-17-2005
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
Please make sure that you have read our rules. And note:
(6) Do not post classroom or homework problems.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:19 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0