basic pointer question need help
I'm trying to work with a dynamically sized "array" of a structure called atoms. I declare an atom pointer like so:
atom *atoms;
Then, I allocated memory for a bunch of atom structures like so:
atoms = (atom *)malloc(100*sizeof(atom));
Then, I loop from 1 to 100 trying to set values in each atom structure from one to 100 by using commands such as:
atoms[i].atom_name = atom_name_variable;
atoms[i].atom_type = atom_type_variable;
However, when I break out of this for loop, and using Microsofts Visual C++ debugger, I only have one atom object, the first one I processed and not 100 like I should have. What am I doing wrong here?