i have two .cpp files (actually three but one isnt giving me this problem)
in ISBN.cpp the decode function is calling ISBNPrefix's FILE fp
ISBN.cpp: <<this is the implementation file where ISBNPrefix's FILE fp is being called
Code:
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cctype>
using namespace std;
#include "ISBN.h"
//code....
.
.
.
int ISBN::decode(const ISBNPrefix& list){
/* *DECODE THE ISBN* */
int area1 = 0, b=1, n=0, min, length, publoop = 0, pub, checkpublenght, pubcheckloop=0, publenght, publisherloop=0, area_pub, titlelenght, ret=0;
char o[11], areatostring[7], publishercheck[8], arealoop[7], pub1loop[7], pub2loop[7], pubsend[8], title1[8];
strcpy(o,ISBN1);
area1 = o[0] - 48;
if(valid(ISBN1)==0){/*check if number is valid first*/
ret = 0;
}
else {/*if valid start decoding*/
while (n!=1){
if(list.registered(area1)==1) {
min = list.minNoDigits(area1);/*get the minimum digits for publisher*/
sprintf(areatostring, "%i", area1);
length = strlen(areatostring);
strcpy(publishercheck-length,o);/*take the area out str for checking*/
sprintf(areatostring, "%i", area1);
rewind(list.fp);
while (!feof(list.fp)) {/*find the amount of time the area to check comes up*/
fscanf(list.fp, "%s %s %s", arealoop, pub1loop, pub2loop);
if(strcmp(areatostring,arealoop)==0){
publoop++;
}
}
if(publoop==8){
publoop=7;
}
while (publisherloop!=1) {
strncpy(pubsend,publishercheck,min);
pubsend[min] = '\0';
pub = atoi(pubsend);
fscanf(list.fp, "%s %s %s", arealoop, pub1loop, pub2loop);
if(list.registered(area1, pubsend)==1){/*if publisher is found*/
strcpy(area,areatostring);/*area equals the area sent*/
strcpy(publisher,pubsend);
area_pub = strlen(area) + strlen(publisher);
titlelenght = 10 - area_pub - 1;
strcpy(title1-area_pub,o);/*find lenght to determine the title and take out the check digit*/
strncpy(title,title1,titlelenght);
title[titlelenght] = '\0';
n = 1;/*stop loop, everything is found*/
publisherloop = 1;
ret = 1;/*return is now true*/
}
else {
min++;
}
}
}
else{/*if check is false add an addition digits to the area*/
area1 = area1 * 10 + (o[b] - 48);
b++;
if(b>5){/*if the area goes over 5 checks there is no valid area*/
n = 1;
ret = 0;
}
}
}
}
return ret;
}
.
.
.
ISBN.h:
Code:
#include <cstdio>
#include <cstring>
#include <iostream>
#ifndef ISBN_H
#define ISBN_H
#endif
#include "ISBNPrefix.h"
class ISBNPrefix;
int valid(const char* str);
class ISBN{
char ISBN1[11];
char area[6];
char publisher[8];
char title[8];
char s;
int isRegistered;
int decode(const ISBNPrefix& list);
public:
ISBN();
ISBN(const char* str, const ISBNPrefix& list);
~ISBN();
void style(char c);
int empty() const;
int registered() const;
void toStr(char* isbn) const;
void toStrWithStyle(char* isbn) const;
void display(ostream& os) const; /* not */
int accept(istream& is, const ISBNPrefix& list);
friend int operator==(const ISBN& left, const ISBN& right);
};
ISBNPrefix.h: <<this is the header file for ISBNPREFIX where FILE fp is declared
Code:
/*Matthew Faria*/
/*Assignment 2*/
/*ISBNPrefix.h*/
/*Header file for IBSNPrefix.h*/
class ISBNPrefix{
FILE* fp;
public:
ISBNPrefix(const char* filename);
ISBNPrefix(const ISBNPrefix& source);
~ISBNPrefix();
int registered(int area) const;
int minNoDigits(int area) const;
int registered(int area, const char* publisher) const;
ISBNPrefix& operator=(const ISBNPrefix& source);
};
anyone know how i can fix this?