ISBN.h
int isValid(const char str[]);
int isRegistered(FILE* fp, const char str[], char area[], char publisher[], char title[]);
error:
ISBN.h:2:18: error: FILE was not declared in this scope
ISBN.h:2:24: error: fp was not declared in this scope
ISBN.h:2:28: error: expected primary-expression before const
ISBN.h:2:46: error: expected primary-expression before char
ISBN.h:2:59: error: expected primary-expression before char
ISBN.h:2:77: error: expected primary-expression before char
ISBN.h:2:89: error: expression list treated as compound expression in initializer [-fpermissive]
Not sure I understand the error as I have another header file with the same sort of parameters that doesn’t yield any errors:
ISBNPrefix.h
FILE* open(const char filename[]);
int isRegistered(FILE* fp, int area);
int minNoDigits(FILE* fp, int area);
int isRegistered(FILE* fp, int area, const char publisher[]);
int close(FILE* fp);
- These function prototypes are given to us by our professor.
isRegisteredis defined three times but with a different amount of paramaters, so when you use the function inmainwith X amount of parameters, will it just use the corresponding version with said parameters?-
I get a second set of errors corresponding to my
ISBN.cppwhich includes myISBN.h:ISBN.cpp: In function int isRegistered(FILE*, const char*, char*, char*, char*):
ISBN.cpp:36:89: error: int isRegistered(FILE*, const char*, char*, char*, char*) redeclared as different kind of symbol
ISBN.h:2:5: error: previous declaration of int isRegistered
ISBN.cpp
#include "ISBN.h"
#include <cstring>
#include <iostream>
#include <cstdio>
using namespace std;
int isValid(const char str[])
{
}
int isRegistered(FILE* fp, const char str[], char area[], char publisher[], char title[])
{
}
FILEis part of the<cstdio>header, which is not included before you start using it in your header. It’s just like how you have to#include <iostream>to usestd::cout. You should generally include every header you need on a per-file basis and not rely on other files to include them for you.Another thing to note is that you should usually deal with the first listed error before others. One error can cause a chain reaction of nonsensical errors and end up putting you off track very easily.