![]() |
School of Engineering and
Applied
Science Department of Computer Science CSci 49 -- Introduction to C Computing http://www.seas.gwu.edu/~csci49/spring06 Prof. Michael B. Feldman mfeldman@gwu.edu |
For example, if the user enters a starting date of May 10, 1999 and an ending date of September 15, 2002, the file will contain a line for each day from May 10 through December of 1999, all of 2000, all of 2001, and all dates in 2002 through September 15. Remember, when turning in your results,be sure to include these output files in their complete and unedited form. This may mean that there will be several pages to turn in.
Your dates should be output in the following format:
In this project you are NOT required to validate the dates or to test with invalid ones; you can assume the user will always enter valid data. However, your test plan must include several date ranges that will test whether your program "rolls over" properly from month to month and year to year. In the next project we'll combine this project with the Project 4 validation ideas.
1.
/*------------------------------------------------------------
2. | ShowFile.c
3. | You can use this as a starting point for your
projects.
4. | Demonstrates the use of an output file.
5. | Writes a 10 x 10 multiplication table to a file.
6. | Author: Michael Feldman, The George Washington
University
7. | Last Modified: March 21, 2006
8.
------------------------------------------------------------*/
9. #include <stdio.h>
10. int main()
11. {
12. const int MAX = 10;
13. int row,
column; /* rows and columns
of table */
14. FILE *myOutput;
15.
16. /* The next statement associates the program
variable myOutput
17. with a new output file that
will be named multi.txt */
18. myOutput = fopen ("multi.txt",
"w"); /*
19.
20. /* now write row x column products into file */
21. for (row = 1; row <= MAX; row++)
22. {
23. for (column = 1; column <=
MAX; column++)
24. {
25. fprintf
(myOutput, "%4d", row * column);
26. }
27. fprintf (myOutput, "\n");
28. }
29.
30. /* Be sure to close the file at the end! */
31. fclose(myOutput);
32. printf ("Output file multi.txt has been
created.\n");
33.
34. return 0;
35. }
Here are the key things to notice and incorporate in your program:
Your grade will be calculated on a 20-point basis, as follows:
MBF 3/21/06