Recent content by TruthOasis

  1. T

    How to Extract Atomic Numbers from a Text File into an Array in C?

    Nevermind I found the problem. Seems I was going way to far in my for loop like you thought. Got it all to work! Thanks for all your help!
  2. T

    How to Extract Atomic Numbers from a Text File into an Array in C?

    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?
  3. T

    How to Extract Atomic Numbers from a Text File into an Array in C?

    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)...
  4. T

    How to Extract Atomic Numbers from a Text File into an Array in C?

    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...
  5. T

    How to Extract Atomic Numbers from a Text File into an Array in C?

    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")...
  6. T

    How to Extract Atomic Numbers from a Text File into an Array in C?

    doesn't scanf() just take input from the user? How do I incorporate that into the program? Would i put in my for loop: scanf(%d,myStr) ?
  7. T

    How to Extract Atomic Numbers from a Text File into an Array in C?

    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...
Back
Top