Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<conio.h>
- #include<string>
- using namespace std;
- struct Date {
- int month;
- int day;
- int year;
- };
- struct Time {
- int hour;
- int minute;
- };
- struct Event {
- char desc[80];
- Date date;
- Time time;
- };
- int read_Events(Event* Eptr[50], int MAX);
- void display(Event* Eptr[50],int(*read_events)(Event , int )) //1. can i
- do this?;
- int main() {
- Event* Eptr[50];
- int *Fptr = &read_Events;//#2 Is this possible? (function address
- to pass as arugement in display function)
- _getch();
- return 0;
- }
- int read_Events(Event* Eptr[50], int MAX) {
- bool repeat = true;
- char ans;
- char slash;
- char colon;
- int i = 0;
- while (repeat && i < MAX) {
- cout << "nWould you like to add a new event [y/n]? ";
- cin >> ans;
- if (ans == 'Y' || 'y') {
- Eptr[i] = new Event;
- repeat = true;
- cout << "nEnter description: ";
- cin.clear();
- cin.ignore(256, 'n');
- cin.getline(Eptr[i]->desc, sizeof(Eptr[i]->desc));
- cout << "nEnter Date(MM/DD/YYYY): ";
- cin >> Eptr[i]->date.month >> slash >> Eptr[i]->date.day >>
- slash >> Eptr[i]->date.year;
- cout << "nEnter time(HH:MM): ";
- cin >> Eptr[i]->time.hour >> colon >> Eptr[i]->time.minute;
- }
- else {
- repeat = false;
- return i;
- }
- i++;
- }
- return i; //returning number of events
- }
- It seems as if what I have done so far is not syntactically correct.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement