I am trying to write a program that reads elements and their relative abundances from a file, then to sort them alphabetically or in order of abundance. however i have been having problems with the part involving structures and arrays to read the data from the file and get it into a format that can be sorted in the desired manner.
My code so far is
printf("\nPlease input a file name including extension\n");
if (!f) return 1;
while (fgets (s,1000,f)!=NULL)
printf("how would you like the data sorted?\n press 1 if you would like the data sorted alphabetically by name of element, or press 2 to sort data by ascending percentage abundance\n ");
if(y == 1) /*alphabet*/
else if (y == 2) /*number*/
a sample input is:
if anyone has any pointers or help to offer, i would be very grateful.