- #1
TruthOasis
- 7
- 0
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 atomicnumber[1000];
int i;
int j=0;
fp = fopen("elements.txt","r");
for (i=0;i<600;i++)
{
j++;
fgets(myStr,600,fp);
if ((i) % 3 ==5)
{
myStr=atomicnumber[j];
}
}
fclose(fp);
How would I get those numbers into an array like atomicnumber[1000]={89,13,95...} ?
Any help would be greatly appreciated.
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 atomicnumber[1000];
int i;
int j=0;
fp = fopen("elements.txt","r");
for (i=0;i<600;i++)
{
j++;
fgets(myStr,600,fp);
if ((i) % 3 ==5)
{
myStr=atomicnumber[j];
}
}
fclose(fp);
How would I get those numbers into an array like atomicnumber[1000]={89,13,95...} ?
Any help would be greatly appreciated.