it works for me...
oh and a couple of notes
you might want to shorten these
Code:
infile.getline(element[i].symbol, 256, ','||'\n');
infile.getline(element[i].name, 256, ','||'\n');
to these
Code:
infile.getline(element[i].symbol, 2, ','||'\n');
infile.getline(element[i].name, 25, ','||'\n');
in order to avoid buffer overruns...
and did you ever check if you actually opened the file successfully?
do something like
Code:
if(!infile)
{
cout << "Error! could not load CHEM.DAT";
return 1;
}
right after your infile.open statement.
(edit)
oh and one other thing... don't you want to use floats instead of ints for your weight variables?
and use the atof() function I think it is, rather than atoi().
Cause if you use int you will lose whatever is after the decimal point..
(/edit)