Guest User

Untitled

a guest
Aug 19th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. Specify a Date structure with month, day and year as its int members.
  2.  
  3. Declare an array of Date pointers initialized to 0 and pass the array to an input function to read dates from the user. Have the user enter as many dates as desired in mm/dd/yyyy format, saving each in a dynamically created structure and storing its pointer in the array of Date pointers. When finished entering, the user will enter a 0 (for the month of the date - the first field) followed by RETURN. The function must return the number of dates entered by the user.
  4.  
  5. Pass the array of Date pointers to a display function to display all dates each on a separate line.
  6.  
  7. Pass the array of Date pointers to a sort function to sort them in ascending order. Remember that you're sorting the pointers, not the structures.
  8.  
  9. Display again all dates after sorting them using the same display function.
  10.  
  11. Save all dates to a file called "Dates.dat" using their pointers stored in the array. You want to save the actual structures not their pointers.
  12.  
  13. Then, make sure the file pointer is at the top of the file. Ask the user to enter a month and pass the file (how do you pass a file to a function? by value or by reference?), the month and an array of Date structures to a search function to find all dates with the specified month that are stored in the file and store them in the array of Date structures (the third parameter). Return number of dates found for the given month. If any was found, print them in main off the array that gets populated by the search function.
  14.  
  15. Here is what the program looks like when it's executed:
  16.  
  17. Enter date (0 to end): 6/18/2012
  18.  
  19. Enter date (0 to end): 5/31/2012
  20.  
  21. Enter date (0 to end): 5/28/2012
  22.  
  23. Enter date (0 to end): 6/14/2012
  24.  
  25. Dates list:
  26.  
  27. 6/18/2012
  28. 5/31/2012
  29. 5/28/2012
  30. 6/14/2012
  31.  
  32. Sorted Dates list:
  33. 5/28/2012
  34. 5/31/2012
  35. 6/14/2012
  36. 6/18/2012
  37.  
  38. Enter month to search for: 6
  39. 6/14/2012
  40. 6/18/2012
  41.  
  42. Press any key to continue.
Add Comment
Please, Sign In to add comment