******************* No errors or warnings ******************* code:
/* headers */ #include <iostream> #include <string> #include <fstream> #include <apvector.h> #include <conio.c> /* End of headers */
int debug(int error); int instr(); int read(); int remove(); int add(); int main();
/* Declaration of namespace */ using namespace std; /* End of decaration of namespace */
/* Error Vars */ int error1, error2, error3; /* End of Error Vars */
/* Functions */
int main() { int menuoption; cout<<"Database v1.0.1"<<endl; cout<<"---------------"<<endl; cout<<endl; if(error2!=10064) { cout<<" [1] Add to database"<<endl; } cout<<" [2] Remove files from database"<<endl; if(error1!=13100) { cout<<" [3] Read files from database"<<endl; } cout<<" [4] Instructions"<<endl; cout<<" [0] Leave"<<endl;
cin>>menuoption;
switch(menuoption) { case 0: return 0; break; case 1: add(); break; case 2: remove(); break; case 3: read(); break; case 4: instr(); break; default: error3=12002; debug(error3); break; } }
int debug(int error) { switch(error) { case 12002: cout<<"Error 12002: Unidentified User Input"<<endl; cout<<"Restarting Program"<<endl; system("pause"); clrscr(); break; case 13100: cout<<"sjlfdk"<<endl; system("pause"); clrscr(); break; case 10064: cout<<"sldfkj"<<endl; system("pause"); clrscr(); break; default: cout<<"Unidentified Error: Please contact your local distributor for assistance."<<endl; system("pause"); return 0; break; } }
int instr() { // instructions here system("pause"); clrscr(); }
int read() { ifstream fin; apvector<char> vectors(100); string line=""; int v; fin.open("Database.txt", ios::in); if(fin) { for(v=1;v<=100;v++) { fin>>vectors[v]; } for(v=1;v<=100;v++) { cout<<vectors[v]<<endl; v=v++; cout<<vectors[v]<<endl; v=v++; cout<<vectors[v]<<endl; cout<<endl; } fin.close(); } else { error1=13100; debug(error1); } system("pause"); clrscr(); }
int remove() { // remove files system("pause"); clrscr(); }
int add() { ofstream fout; char status[201] =""; char age[201] = ""; char name[201] = ""; cout<<"Name: "; cin.getline(name, 200); cout<<"Age: "; cin.getline(age, 200); cout<<"Status: "; cin.getline(status, 200); if(fout) { fout.open("Database.txt", ios::app); fout<<name<<endl; fout<<age<<endl; fout<<status<<endl; fout.close(); } else { error2=10064; debug(error2); } system("pause"); clrscr(); }
ross
I am running Dev 4.9.6.9 (lastest vUpdate) with all of the packages installed and I can't find apvector.h can you please send that to?
Thanks Curtis
apvector.h and apvector.cpp can be downloaded at http://www.collegeboard.com/ap/students/classes.html
(i saved them to c:/dev/include/ )
Page doesn't work
Curtis
oops sry its http://www.collegeboard.com/ap/students/compsci/classes.html i forgot the compsci sry =)
Log in to post a comment.
*******************
No errors or warnings
*******************
code:
/* headers */
#include <iostream>
#include <string>
#include <fstream>
#include <apvector.h>
#include <conio.c>
/* End of headers */
int debug(int error);
int instr();
int read();
int remove();
int add();
int main();
/* Declaration of namespace */
using namespace std;
/* End of decaration of namespace */
/* Error Vars */
int error1, error2, error3;
/* End of Error Vars */
/* Functions */
int main()
{
int menuoption;
cout<<"Database v1.0.1"<<endl;
cout<<"---------------"<<endl;
cout<<endl;
if(error2!=10064)
{
cout<<" [1] Add to database"<<endl;
}
cout<<" [2] Remove files from database"<<endl;
if(error1!=13100)
{
cout<<" [3] Read files from database"<<endl;
}
cout<<" [4] Instructions"<<endl;
cout<<" [0] Leave"<<endl;
cin>>menuoption;
switch(menuoption)
{
case 0:
return 0;
break;
case 1:
add();
break;
case 2:
remove();
break;
case 3:
read();
break;
case 4:
instr();
break;
default:
error3=12002;
debug(error3);
break;
}
}
int debug(int error)
{
switch(error)
{
case 12002:
cout<<"Error 12002: Unidentified User Input"<<endl;
cout<<"Restarting Program"<<endl;
system("pause");
clrscr();
break;
case 13100:
cout<<"sjlfdk"<<endl;
system("pause");
clrscr();
break;
case 10064:
cout<<"sldfkj"<<endl;
system("pause");
clrscr();
break;
default:
cout<<"Unidentified Error: Please contact your local distributor for assistance."<<endl;
system("pause");
return 0;
break;
}
}
int instr()
{
// instructions here
system("pause");
clrscr();
}
int read()
{
ifstream fin;
apvector<char> vectors(100);
string line="";
int v;
fin.open("Database.txt", ios::in);
if(fin)
{
for(v=1;v<=100;v++)
{
fin>>vectors[v];
}
for(v=1;v<=100;v++)
{
cout<<vectors[v]<<endl;
v=v++;
cout<<vectors[v]<<endl;
v=v++;
cout<<vectors[v]<<endl;
cout<<endl;
}
fin.close();
}
else
{
error1=13100;
debug(error1);
}
system("pause");
clrscr();
}
int remove()
{
// remove files
system("pause");
clrscr();
}
int add()
{
ofstream fout;
char status[201] ="";
char age[201] = "";
char name[201] = "";
cout<<"Name: ";
cin.getline(name, 200);
cout<<"Age: ";
cin.getline(age, 200);
cout<<"Status: ";
cin.getline(status, 200);
if(fout)
{
fout.open("Database.txt", ios::app);
fout<<name<<endl;
fout<<age<<endl;
fout<<status<<endl;
fout.close();
}
else
{
error2=10064;
debug(error2);
}
system("pause");
clrscr();
}
ross
I am running Dev 4.9.6.9 (lastest vUpdate) with all of the packages installed and I can't find apvector.h can you please send that to?
Thanks
Curtis
apvector.h and apvector.cpp can be downloaded at http://www.collegeboard.com/ap/students/classes.html
(i saved them to c:/dev/include/ )
Page doesn't work
Curtis
oops sry its http://www.collegeboard.com/ap/students/compsci/classes.html i forgot the compsci sry =)