Program to Calculate Molar Mass
I need to write a C program to calculate the molar mass when given a chemical formula. For example: C6H13NO2.
I've gotten my code to get the formula into a string and validate it. I've stored the possible atomic masses (C,H,N,O,S) in an array. And I'm using a for loop to process the values in the formula string.
What I can't figure out is how to put the digits in the formula together as an integer value and multiply that value by the atomic mass represented by the preceding letter.