Thanks to coder 777 my code "works", it just doesn't do what I was hoping it would. I want it to calculate the weight of a compound (the reason for the first 20 elements as floating numbers) but I don't know how to do that yet, especially considering I have no idea how many variables are going to be used.
It needs to
Thank you in advance!
#include <iostream>
#include <fstream>
usingnamespace std;
int main()
{
float h = 1.0079;
float he = 4.002;
float li = 6.941;
float be = 9.012;
float b = 10.811;
float c = 12.0107;
float n = 14.0067;
float o = 15.9994;
float f = 18.998;
float ne = 20.1797;
float na = 22.989;
float mg = 24.3050;
float al = 26.981;
float si = 28.0855;
float p = 30.973;
float s = 32.065;
float cl = 35.453;
float ar = 39.948;
float k = 39.948;
float ca = 40.078;
char number[101];
char cmpnd[101];
cout << "Please input chemical formula with * between every symbol.\n all lower case please\n example: si o 2" << endl;
cin.getline (cmpnd, 101);
ofstream a_file ( "calculator.txt" );
a_file<<cmpnd;
a_file.close();
ifstream b_file ( "calculator.txt" );
b_file>>cmpnd;
number[101] = cmpnd[101];
cout<<number;
}