Hello everybody, im new here. I am trying to make a program about chemistry periodic table. I have the following problem. The user has to tell the program a compound formula. For example HCl, and the program must tell the user it's name in words. I can make it with one letter formula's as H->Hydrogen, Na->Sodium. But when there are two letters, i can't sepparate them. For example. NaCl means sodium chloride, but i can't identify what is chloride and what is sodium when all the letters are together. What can I do? Thanks.
You should know the Rule of chemistry Cl will start with a capital letter and thats where you can detect the end of one element and start of second.
I add two questions more, if anyone can help me. When i type scanf("%c" compound) and i write HCl, the program says 'overflow'. I know character constants can only accepts one letter, not three (as in HCl). How could i introduce this formula into the computer in order to analyse it's parts? (H and Cl). Also, which is the command that reads this? . I am very newbie in C I only know some commands, the most i've used is while and switch.
Hello. I am very sorry for not having answered yet since your last answer. Thank you very much shabbir.