So i'm making this periodic table kinda program here mainly outta boredom. But I came across a problem, when I type in the name for the element, the program just closes. Any ideas on how to get it to work properly. Here's my current code.
#include <iostream>
#include <windows.h>
#include <stdlib.h>
using namespace std;
char elementname[100];
char mainmenuyesno[20];
int consoletextcolour;
HANDLE hConsole;
int main () {
consoletextcolour = 234;
SetConsoleTextAttribute(hConsole, consoletextcolour);
mainmenu:
cout <<"Welcome to Valestrom's Periodic Table"<<endl;
Sleep(5000);
cout <<"Please report any problems to Blackmethod@gmx.com"<<endl;
Sleep(7500);
system("cls");
cout <<"Valestrom's Periodic table. By Blackmethod and Valestrom"<<endl;
cout <<"Press ENTER/RETURN to continue";
cin.get();
system("cls");
cout <<"Valestrom's periodic table V1.0"<<endl;
cout <<"Type the name of an element to get info on it: ";
cin.getline(elementname, 100);
if (elementname == "Lithium" || elementname == "Li")
do {
system("cls");
cout <<"LITHIUM (Li): Atomic Weight: 6.941" <<endl;
cout <<"Ionic Charge: +1, Melting Point: 180.54 C" <<endl;
cout <<"Boiling Point: 1342 °C"<<endl;
cout <<"Return to main menu? Yes/No: ";
cin.getline (mainmenuyesno, 20);
if (mainmenuyesno == "Yes")
goto mainmenu;
else
exit(1);
} while (elementname == "Lithium" || elementname == "Li");
if (elementname == "Hydrogen" || elementname == "H")
do {
system("cls");
cout <<"HYDROGEN (H): Atomic Weight: 1.00794" <<endl;
cout<<"Ionic Charge: +1 -1, Melting Point: -259.14 C" <<endl;
cout<<"Boiling Point: -252.87 C"<<endl;
cout <<"Return to main menu? Yes/No: ";
cin.getline (mainmenuyesno, 20);
if (mainmenuyesno == "Yes")
goto mainmenu;
else
exit(1);
} while (elementname == "Hydrogen" || elementname == "H");
end:
return 0;
}