Right I wrote this code and i need to modify it now to account for other problems so.. the code is as follows.
With this i need to make the code read and summarise a file containing this table;
printf ("Petrol 2.3kg CO2 / unit\nOil 2.3kg CO2 / unit\nCoal 2.3kg CO2 / unit\nWood 2.3kg CO2 / unit\n");
printf ("Electricity 2.3kg CO2 / unit \nNatural gas 2.3kg CO2 / unit \nAir travel 2.3kg CO2 / unit \n\n\n");
printf ("State your fuel use or way of travel\n");
printf (" 1. Petrol\n 2. Oil\n 3. Coal\n 4. Wood\n 5. Electricity\n 6. Natural gas\n 7. Air Travel ");
scanf ( "%d", &fuel);
printf("you are using %f of kg CO2 by using Petrol\n", (float)fuel * 2.3);
printf("you are using %f of kg CO2 by using Oil\n", (float)fuel * 2.7);
printf("you are using %f of kg CO2 by using Coal\n", (float)fuel * 2.4);
printf("you are using %f of kg CO2 by using Wood\n", (float)fuel * 0.0);
printf("you are using %f of kg CO2 by using Electricity\n", (float)fuel * 0.4);
printf("you are using %f of kg CO2 by using Natural Gas\n", (float)fuel * 0.2);
printf("you are using %f of kg CO2 by using Air Travel\n", (float)fuel * 0.3);
printf("Would you like to do it again?(Y/N): ");
c = toupper(getchar());
if(c == 'Y')
printf("How much fuel is being used?: ");
while( c != 'N');
The program has to also analyse a file containing any number of lines and not in any order. The first column should be a single word describing the fuel/activity. i have to have the following declarations in force: double amount;
char fuel,description 
one line of the code can be read using
fscanf(fptr," %19s %lf %39[^\n]",fuel,&amount,description);
I have to give the total CO2 emision in kg together with the equivalent number of CO2 ”rations” (where a CO2 ration is 2500 kg)
I need to provide a breakdown of the emissions, listing the
emission corresponding to each line in the file
and the total for each kind of emission (e.g.
Car, Flight etc etc..) I should contain and use a function declared as:
double co2(char fuel, double amount)
My program will need to make use ofthe strncmp function.
I know this may seem like im asking for work to be done but i only need steps in right direction as ive already written code and not asking all to be done by you just pointers and explaining how i can do this.