Answered step by step
Verified Expert Solution
Question
1 Approved Answer
help... it seems like .h file theres an error. can someone tell me what went wrong. The checkIFPresent went wrong. Please help me Phone.h :
help... it seems like .h file theres an error. can someone tell me what went wrong. The checkIFPresent went wrong. Please help me
Phone.h :
#ifndef NAMESPACE_PHONE_H
#define NAMESPACE_PHONE_H
using namespace std;
namespace sdds
{
void phoneDir(const char* programTitle, const char* fileName);
bool checkIfPresent(char* name, string* partialName);
}
#endif
phone.cpp #include#include #include "cStrTools.h" using namespace std; void phoneDir(const char* programTitle, const char* fileName) { cout << programTitle << "phone directory search "; cout << "------------------------------------------------------- "; while (1) { FILE *f = fopen(fileName, "r"); if (!f) { cout << fileName << " file not found! "; break; } else { cout << "Enter a partial name to search (no spaces) or enter '!' to exit >"; string partialName; cin >> partialName; if (partialName == "!") break; char name[50]; int area = 0, prefix = 0, number = 0; while (1) { // cout << "hey"; fscanf(f, "%[^\t]s", name); getc(f); fscanf(f, "%d", &area); getc(f); fscanf(f, "%d", &prefix); getc(f); fscanf(f, "%d", &number); if (getc(f) == EOF) break; // cout << name << " " << area << " "; if (checkIfPresent(name, partialName)) cout << name << ": (" << area << ") " << prefix << "-" << number << " "; } } fclose(f); } cout << "Thank you for using " << programTitle << " directory. "; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started