Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. #include<iostream>
  2. #include<conio.h>
  3. #include<string>
  4. using namespace std;
  5. struct Date {
  6. int month;
  7. int day;
  8. int year;
  9. };
  10. struct Time {
  11. int hour;
  12. int minute;
  13. };
  14. struct Event {
  15. char desc[80];
  16. Date date;
  17. Time time;
  18. };
  19.  
  20. int read_Events(Event* Eptr[50], int MAX);
  21. void display(Event* Eptr[50],int(*read_events)(Event , int )) //1. can i
  22. do this?;
  23. int main() {
  24. Event* Eptr[50];
  25. int *Fptr = &read_Events;//#2 Is this possible? (function address
  26. to pass as arugement in display function)
  27.  
  28. _getch();
  29. return 0;
  30. }
  31.  
  32. int read_Events(Event* Eptr[50], int MAX) {
  33. bool repeat = true;
  34. char ans;
  35. char slash;
  36. char colon;
  37. int i = 0;
  38.  
  39. while (repeat && i < MAX) {
  40. cout << "nWould you like to add a new event [y/n]? ";
  41. cin >> ans;
  42.  
  43. if (ans == 'Y' || 'y') {
  44. Eptr[i] = new Event;
  45. repeat = true;
  46.  
  47. cout << "nEnter description: ";
  48. cin.clear();
  49. cin.ignore(256, 'n');
  50. cin.getline(Eptr[i]->desc, sizeof(Eptr[i]->desc));
  51.  
  52. cout << "nEnter Date(MM/DD/YYYY): ";
  53. cin >> Eptr[i]->date.month >> slash >> Eptr[i]->date.day >>
  54. slash >> Eptr[i]->date.year;
  55.  
  56. cout << "nEnter time(HH:MM): ";
  57. cin >> Eptr[i]->time.hour >> colon >> Eptr[i]->time.minute;
  58. }
  59. else {
  60. repeat = false;
  61. return i;
  62. }
  63. i++;
  64. }
  65. return i; //returning number of events
  66. }
  67.  
  68. It seems as if what I have done so far is not syntactically correct.
  69.  
  70. void display(Event* Eptr[50],int(*read_events)(Event , int )) //1. can i do this?;
  71.  
  72. void display(Event* Eptr[50],int(*read_events)(Event , int ));
  73.  
  74. int *Fptr = &read_Events;//#2 Is this possible?
  75.  
  76. int(*Fptr)(Event , int ) = &read_Events;
  77.  
  78. int(*Fptr)(Event , int ) = read_Events;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement