Hi all. I'm new to C++ and I wrote a program that compiled without errors or warnings but doesn't do what its suppose to do. The program asks for the last name of 1 of 2 authors and then is suppose to display the books written by that author. No matter which name is typed in the program always displays the books written by the second author. I use strcmp and an if/else statement.
Heres my code:
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char Name[30];
char Binchy;
char Pilcher;
cout << "Enter Authors Last Name: \n";
cin >> Name;
if(strcmp(Name,"Binchy")){
cout << " \n";
cout << "The Copper Beach\n";
cout << " \n";
cout << "Light a Penny Candle\n";
cout << " \n";
cout << "The Lilac Bus\n";
cout << " \n";
cout << "Firefly Summer\n";
cout << " \n";
cout << "Scarlet Feather\n";
cout << " \n";
cout << "Sleeping Tiger\n";
cout << " \n";
cout << "The Grass Lake\n";
cout << " \n";
cout << "Silver Wedding\n";
cout << " \n";
cout << "Silver Lake\n";
cout << " \n";
cout << " \n";
}
else
cout << "Snow in April\n";
cout << " \n";
cout << "Voice in Summer\n";
cout << " \n";
cout << "Flowers in the Rain\n";
cout << " \n";
cout << "Coming Home\n";
cout << " \n";
cout << "Shell Seekers\n";
cout << " \n";
cout << "The Empty House\n";
cout << " \n";
cout << "Wild Mountain Thyme\n";
cout << " \n";
cout << "Under Gemini\n";
cout << " \n";
cout << "September\n";
cout << " \n";
cout << " \n";
system("PAUSE");
return 0;
}
Eventually I would like to add an option to add a book to either list but I'll just take one step at a time.
Any help would be appreciated.