I'm provided with a file full of data on a car trip, here's an example:
The 10 is the number of minutes the trip lasted (it will always be a multiple of 5 and less than 30), and the 13 is the radius of the tires. The following numbers on the left represent the revolutions the tires made in a given second, and the right numbers are the gas in gallons used in that second.Code:10 13 1.131232 0.000183 2.872323 0.000312 4.233291 0.000422 5.823823 0.000367 6.464139 0.000316 6.554324 0.000275 6.001023 0.000245 5.293232 0.0 7.012323 0.000612 7.013323 0.000583
Basically we have to ask the user for the file the data is storred in and compile a graph from it like so:
To be honest I'm a bit behind and I'm still having trouble printing out graphs and reading in files. This is what i've got so far:Code:What file stores the car data? sample.txt 95 90 85 80 75 70 65 60 55 50 45 40 35 30 ***** 25 ***** ***** 20 ***** ***** 15 ***** ***** 10 ***** ***** ***** 5 ***** ***** ***** 0 ***** ***** ***** ----------------------------------- 00-05 05-10 10-15 15-20 20-25 25-30
We also have to include a function after the main function and I really lack that knowledge. I'd appreciate it if anyone could get me a direction to go in...Code:#include <stdio.h> int main() { FILE *ifp; int file, rad, mins; double revs, gas; printf("What file stores the car data?\n"); scanf("%d", &file); //Open file ifp = fopen(file, "r"); fscanf(ifp, "%d%d", &mins, &rad);



LinkBack URL
About LinkBacks




