I have the following code:
Code:
#include <iostream>
#include <fstream>
using namespace std;
char academics[1000000];
char sports[1000000];
char extra[1000000];
char id[20];
bool loggedIn=0;
int main()
{
do{
cout<<"Enter ID Number"<<endl;
cin>>id;
if (id=="04390") {
loggedIn=1;
break;
}else{
//repeat above for all other valid id numbers, sort of a catch all so that a slipped finger doesn't make their portfolio unviewable through the viewer.html construct...
loggedIn=0;
break;
}
}while (loggedIn==0);
//read files into strings....
//note that, when using for real project...use fin("f:\\users\\whatever double slash"id"double slash academics.portfolio)...
ifstream afin("c:\\drew\\ElectronicPortfolioFiles\\academics.portfolio");
if (!afin.is_open) {
cerr<<"Error Opening File: 'academics.portfolio'"<<endl;
cerr<<"Make Sure The File Exists And Is In Your ID Folder"<<endl;
exit(1);
}
afin>>academics;
afin.close();
ifstream sfin("c:\\drew\\ElectronicPortfolioFiles\\sports.portfolio");
if (!sfin.is_open) {
cerr<<"Error Opening File: 'sports.portfolio'"<<endl;
cerr<<"Make Sure The File Exists And Is In Your ID Folder"<<endl;
exit(1);
}
sfin>>sports;
sfin.close();
ifstream efin("c:\\drew\\ElectronicPortfolioFiles\\extra.portfolio");
if (!efin.is_open) {
cerr<<"Error Opening File: 'extra.portfolio'"<<endl;
cerr<<"Make Sure The File Exists And Is In Your ID Folder"<<endl;
exit(1);
}
efin>>extra;
efin.close();
char fileExtension[]=".xml";
char* fileName=strcat(id,fileExtension);
ofstream fout(fileName);
if (!fout.is_open) {
cerr<<"Error Compiling Portfolio, Sorry For The Inconvenience."<<endl;
exit(1);
}
fout<<"<?xml version='1.0'?>"<<'\n'<<"<!DOCYPE portfolio ["<<'\n'<<"<!ELEMENT portfolio (academics, sports, extra)>"<<'\n'<<"!ELEMENT academics (#PCDATA) >"<<'\n'<<"!ELEMENT sports (#PCDATA) >"<<'\n'<<"!ELEMENT extra (#PCDATA) >"<<'\n'<<"<portfolio>"<<'\n';
fout<<"<academics>"<<'\n'<<academics<<'\n'<<"</academics>"<<'\n'<<"<sports>"<<'\n'<<sports<<'\n'<<"</sports>"<<'\n'<<"<extra>"<<'\n'<<extra<<'\n'<<"</extra>"<<'\n'<<"</portfolio>";
fout.close();
return 0;
}
upon compiling, i receive the following error:
member function must be called, or it's address taken in function main()
it says that error occurs on a few lines, each happens to be one where i use the ifstream operator....whats up with this code?