Hmmm.. when I try doing that I get an error: subscripted value is neither an array nor a pointer
this only happens when i add the [i] to the atomic mass and atomic number.
Is this because i didn't initialize them correctly? Do I need to set up a pointer variable?
Cool! I took it out of the for loop and removed the [i] and got the first 4 values. So the file is opening correctly.
fp = fopen("elements.txt","r");
fscanf(fp,"%s\n%f\n%s\n%d",elementSymbol,&atomicMass,elementName,&atomicNumber)...
when I set the size of my array, shouldn't i just make it a really big number so the amount of characters or numbers don't exceed that size, until I learn how to use dynamic allocation?
Also, I can't just forget about the abbreviation and name because when I use the fscanf function I need to use...
Ok, i tried to fix it but it isn't working correctly. I get a whole bunch of mess when I try to print the vector.
int main(void)
{
int i;
char elementSymbol[1000];
int atomicNumber[1000];
char elementName[1000];
float atomicMass[1000];
FILE *fp;
fp = fopen("elements.txt","r")...
Hi, I need help taking the atomic numbers from a list of elements and putting them in an array.
I have my data in a text file in the form:
Ac
227
Actinium
89
Al
26.981539
Aluminium
13
Am
243
Americium
95
etc.
This is what I am have so far:
FILE *fp;
char myStr[1000];
char...