This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
haas:summer2017:cprog:projects:sfa0 [2017/07/26 15:33] – [Responsible file access] wedge | haas:summer2017:cprog:projects:sfa0 [2017/07/26 15:59] (current) – [Methods of file access] wedge | ||
---|---|---|---|
Line 167: | Line 167: | ||
* close | * close | ||
- | We'll be specifically focusing on opening, reading, and closing files for this project. | + | We'll be specifically focusing on opening, reading, writing, and closing files for this project. |
A point of distinction on " | A point of distinction on " | ||
Line 254: | Line 254: | ||
For this project, mixing together all the skills we've previously learned and just learned is in order. | For this project, mixing together all the skills we've previously learned and just learned is in order. | ||
- | In **/ | + | In **/ |
+ | < | ||
+ | NAME # 1S 1T 2S 2T 3S 3T ... #S #T | ||
+ | </ | ||
+ | |||
+ | Where: | ||
+ | |||
+ | * the first 8 characters correspond to an ALL UPPERCASE name of an individual (name doesn' | ||
+ | * the # refers to the number of score pairs associated with that individual (will not exceed 127) | ||
+ | * then a set of number pairs (labeled S and T, for Score and Total), that are associated with that individual (individual numbers will not exceed 65535) | ||
+ | |||
+ | It will be your task to write a program that: | ||
+ | * opens that file: | ||
+ | * via its absolute path | ||
+ | * for reading | ||
+ | * load the data for each line into a custom struct you've made that contains the following elements: | ||
+ | * place to store the person' | ||
+ | * store the person' | ||
+ | * array to store the person' | ||
+ | * array to store the corresponding totals for each score | ||
+ | * array to store the average of each score:total pair | ||
+ | * element to store the tally of all the scores | ||
+ | * element to store the tally of all the totals | ||
+ | * element to store the average of the averages | ||
+ | * element to store the average of the tallied scores: | ||
+ | * opens the local file: **sfa0.out** for **writing** | ||
+ | * stores the processed results you have in memory (in your structs), in the following format: | ||
+ | |||
+ | < | ||
+ | Name:#: | ||
+ | </ | ||
+ | |||
+ | Of particular note: | ||
+ | |||
+ | * Name of individual is that changed Uppercase lead-in letter followed by all lowercase | ||
+ | * category fields are separated by colons ':' | ||
+ | * averages should be truncated 2 places after the decimal point | ||
+ | * if rounding occurs, so be it; if not, don't worry about it | ||
+ | * the written out score pairs are done so in reverse order (last to first, although score still precedes total) | ||
+ | * the score is separated from the tally by a comma ',' | ||
+ | * the field separators in the score pairs field are semi-colons ';' | ||
+ | |||
+ | For example, if the source data was: | ||
+ | |||
+ | < | ||
+ | KRIS 2 13 17 9 18 | ||
+ | </ | ||
+ | |||
+ | The corresponding line written out to **sfa0.out** would be: | ||
+ | |||
+ | < | ||
+ | Kris: | ||
+ | </ | ||
+ | |||
+ | Additional constraints: | ||
+ | * use FILE pointers and FILE pointer-oriented C library functions (fopen(), fprintf(), fscanf(), fclose()) | ||
+ | * close all open files when done | ||
+ | * you must have and use 2 FILE pointers | ||
=====Review of Compiling/ | =====Review of Compiling/ | ||
Just to review the compilation/ | Just to review the compilation/ | ||
Line 300: | Line 357: | ||
<cli> | <cli> | ||
- | $ submit cprog fcc0 fcc0.c | + | $ submit cprog sfa0 sfa0.c sfa0.out |
- | Submitting cprog project "fcc0": | + | Submitting cprog project "sfa0": |
- | -> fcc0.c(OK) | + | -> sfa0.c(OK) |
+ | -> sfa0.out(OK) | ||
SUCCESSFULLY SUBMITTED | SUCCESSFULLY SUBMITTED | ||
Line 308: | Line 366: | ||
You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches. | You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches. | ||
- | |||
- | What I'll be looking for: | ||
- | |||
- | < | ||
- | 78: | ||
- | *: | ||
- | *:fcc0:FCC game adequately implemented [6/6] | ||
- | *: | ||
- | *: | ||
- | *: | ||
- | *: | ||
- | *: | ||
- | *: | ||
- | *: | ||
- | *: | ||
- | *: | ||
- | *: | ||
- | *: | ||
- | </ |