Can someone help explain the errors? The errors are right after my question and
ID: 3759649 • Letter: C
Question
Can someone help explain the errors? The errors are right after my question and the program that I wrote is right below! Thanks! Could you also help show me what it should look like? ./CTest.cpp: In function ‘int main()’: ./CTest.cpp:17:5: error: expected ‘;’ before ‘else’ else ^ ./CTest.cpp: In function ‘void lookup()’: ./CTest.cpp:25:2: error: ‘book’ was not declared in this scope book check=false; ^ ./CTest.cpp:25:7: error: expected ‘;’ before ‘check’ book check=false; ^ ./CTest.cpp:31:7: error: ‘fristName’ was not declared in this scope if (fristName.compare(name)==0 || lastName.compare(name)==0) ^ ./CTest.cpp:33:10: error: ‘fistName’ was not declared in this scope cout< 4 #include 5 #include 6 using namespace std; 7 void lookup(); 8 void add(); 9 int main() 10 { 11 12 string type; 13 while (cin>>type) 14 { 15 if (type=="lookup") 16 lookup () 17 else 18 add (); 19 } 20 return 0; 21 } 22 void lookup() 23 { 24 ifstream fin; 25 book check=false; 26 string name, firstName, lastName, email; 27 cin>>name; 28 fin.open("phonebook"); 29 while (fin >> firstName >> lastName >> email) 30 { 31 if (fristName.compare(name)==0 || lastName.compare(name)==0) 32 { 33 cout<
Explanation / Answer
1. bool check=false; //not book
2.fristName.compare(name)==null //not ==0
3. string name; //declare name
if you provide full program in editable format i can provide you with more corrections