[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

03/03/2008 at 02:56PM PST, ID: 23211155
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.3

Placing user generated  char* statement into array of char*s

Asked by pacman32689 in C++ Programming Language

Tags: c++

I believe I am finally making some headway on this cheesy appointment book I am writing. :) However, I have run into some trouble. I have it set so the user can enter up to 10 purposes via giving each appointment day an array of 10 char*s. However, when I go to copy the user input into the the array at a certain position g++ is throwing me the error:

main.cpp:31: error: no matching function for call to 'DailyAppointmentScheduler::setPurpose(const char [12], int)'
DailyAppointmentScheduler.h:29: note: candidates are: void DailyAppointmentScheduler::setPurpose(char**, int)

My understanding is that I am screwing up by trying to find the size of a 2d array item by trying to find the size of it as a 1d array. The two arguments for setPurpose are the actual purpose and then the spot in the array to place it. (I am planning to go back and simply this stuff a lot more, ie combining all the time setting into a single function, but first I have to get the fundamentals right.)

Is there another one of your wonderful examples to set me straight? :) They always help a lot! Thank you.

I also realize my overloaded operators are commented out. My plan was that the << operator would do something alone the lines of cout << Sunday;

And I would get

My daily appointment scheduler for Sunday
10:00 am Go to dentist.
6:30 pm Go to bed.

By making << friends with Date and Time I assume that would be possible. Thanks again!
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
//main.cpp
 
#include <iostream>
#include "Date.h"
#include "Time.h"
#include "DailyAppointmentScheduler.h"
 
using namespace std;
 
int main ()
{
        person = new char[10];
        strcpy(person,"Paul");
        Date march2(3,2,2008);
        Date march3(3,3,2008);
        Date march4(3,4,2008);
        Date march5(3,5,2008);
        Date march6(3,6,2008);
        Date march7(3,7,2008);
        Date march8(3,8,2008);
        Time su[10];
        Time m[10];
        Time tu[10];
        Time w[10];
        Time th[10];
        Time f[10];
        Time sa[10];
        DailyAppointmentScheduler Sunday(march2,su[10]);
        DailyAppointmentScheduler Monday(march3,m[10]);
        DailyAppointmentScheduler Tuesday(march4,tu[10]);
        DailyAppointmentScheduler Wednesday(march5,w[10]);
        DailyAppointmentScheduler Thursday(march6,th[10]);
        DailyAppointmentScheduler Friday(march7,f[10]);
        DailyAppointmentScheduler Saturday(march8,sa[10]);
        Sunday.setPurpose("Go to jail.",0);
        su[0].setMinutes(30);
        su[0].setHours(12);
        su[0].setTimeOfDay(true);
        Sunday.setPurpose("Get out of jail.",1);
        Sunday.setMinutes(45);
        su[1].setHours(6);
        su[1].setTimeOfDay(true);
        Monday.setPurpose("Brush Teeth", 9);
        m[9].setMinutes(30);
        m[9].setHours(7);
        m[9].setTimeOfDay(false);
        Monday.setPurpose("Go to sleep",3);
        m[3].setMinutes(45);
        m[3].setHours(8);
        m[3].setTimeOfDay(true);
        Tuesday.setPurpose("Go to class.",4);
        tu[4].setMinutes(50);
        tu[4].setHours(2);
        tu[4].setTimeOfDay(true);
        Wednesday.setPurpose("Read book.", 6);
        w[6].setMinutes(27);
        w[6].setHours(5);
w[6].setTimeOfDay(true);
        Thursday.setPurpose("Take test.", 7);
        th[7].setMinutes(22);
        th[7].setHours(9);
        th[7].setTimeOfDay(false);
        Friday.setPurpose("Go to the club.",0);
        f[0].setMinutes(0);  
        f[0].setHours(7);  
        f[0].setTimeOfDay(true); 
        Saturday.setPurpose("Try to start program early.",0);
        sa[0].setMinutes(10); 
        sa[0].setHours(2);
        sa[0].setTimeOfDay(true);
        
}
        
//Time.h
 
#include <iostream>
#ifndef TIME_H
#define TIME_H
class Time
{
        private:
                        int minutes;
                        int hours;
                        bool timeOfDay;
        public:
                Time();
                Time(int,int,bool);
                int getMinutes();
                int getHours();
                void setMinutes(int);
                void setHours(int);
                void setTimeOfDay(bool);
                bool getTimeOfDay();
};
#endif
 
Time.cpp
 
#include "Time.h"
 
Time::Time()
{
        hours = 0;
        minutes = 0;
        setTimeOfDay = false;
}
Time::Time(int hours1, int minutes, bool timeOfDay1)
{
        hours = hours1;
        minutes = minutes;
        timeOfDay = timeOfDay1;
}
int Time::getMinutes()
{
        return minutes;
}
 
void Time::setMinutes(int newMinutes)
{
        minutes = newMinutes;
}
 
int Time::getHours()
{
        return hours;
}
void Time::setHours(int newHours)
{
        hours = newHours;
}
bool Time::getTimeOfDay()
{
        return timeOfDay;
}
void Time::setTimeOfDay(bool newTimeOfDay)
{
        timeOfDay = newTimeOfDay;
}
 
 
//date.h
 
#ifndef DATE_H
#define DATE_H
#include <iostream>
 
class Date
{
        private:
                        int month;
                        int day;
                        int year;
        public:
                        Date();
                        Date(int,int,int);
                        int getMonth();
                        void setMonth(int);
                        int getDay();
                        void setDay(int);
                        int getYear();
                        void setYear(int);
};
#endif
 
//Date.cpp
 
#include "Date.h"
#include <iostream>
 
Date::Date()
{
        day = 0;
        month = 0;
        year = 0;
}
Date::Date(int day1, int month1, int year1)
{
        day = day1;
        month = month1;
        year = year1;
}
int Date::getMonth()
{
        return month;
}
 
void Date::setMonth(int newMonth)
{
        month = newMonth;
}
 
int Date::getDay()
{
        return day;
}
 
void Date::setDay(int newDay)
{
        day = newDay;
}
 
int Date::getYear()
{
        return year;
}
 
void Date::setYear(int newYear)
{
        year = newYear;
}
 
//DailyAppointmentScheduler.h
 
#include <iostream>
#include "Date.h"
#include "Time.h"
#ifndef DAILYAPPOINTMENTSCHEDULER_H
#define DAILYAPPOINTMENTSCHEDULER_H
 
class DailyAppointmentScheduler
{
        private:
                        static char* person;
                        char* purpose[10];
                        Date calendarDate;
                        Time calendarTime[10];
        public:
                        DailyAppointmentScheduler();
                        DailyAppointmentScheduler(Date,Time);
                        const char* getPerson() const;
                        void setPerson(char*);
                        const char* getPurpose() const;
                        void setPurpose(char**,int);
                        ~DailyAppointmentScheduler();
                        DailyAppointmentScheduler &operator=(const DailyAppointmentScheduler&);
                        friend std::ostream& operator<<(std::ostream &os, const Date &d);
                        friend std::ostream& operator<<(std::ostream &os, const Time &t);
};
#endif
 
//DailyAppointmentScheduler.cpp
 
#include "DailyAppointmentScheduler.h"
#include "Time.h"
#include "Date.h"
 
#include <iostream>
 
using namespace std;
 
char * DailyAppointmentScheduler::person = NULL;
 
DailyAppointmentScheduler::DailyAppointmentScheduler()
{
}
DailyAppointmentScheduler::DailyAppointmentScheduler(Date,Time)
{
}
const char* DailyAppointmentScheduler::getPerson() const
{
        return person;
}
void DailyAppointmentScheduler::setPerson(char* newPerson)
{
        delete [] person;
        person = new char[strlen(newPerson+1)];
        strcpy(person,newPerson);
}
const char* DailyAppointmentScheduler::getPurpose() const
{
        return **purpose;
}
void DailyAppointmentScheduler::setPurpose(char** newPurpose, int spot)
{
        purpose[spot] = new char[strlen(newPurpose)+1];
        strcpy(purpose,newPurpose);
        delete [] newPurpose;
}
DailyAppointmentScheduler::~DailyAppointmentScheduler()
{
        delete [] purpose;
        delete person;
}
DailyAppointmentScheduler& DailyAppointmentScheduler::operator=(const DailyAppointmentScheduler& p)
{
    return *this;
}
ostream& operator << (ostream& os, const DailyAppointmentScheduler& s)
{
//      os << s.getPerson() << endl;
//      os << s.getDay() << " " << s.getMonth() << " " s.getYear() <<endl;
//      os << s.getHours() << ":" << s.getMinutes() << " ";
//      if(s.getAmOrPm() == false)
//      {
//              os << "am" << endl;
//      }
//      else
//      {
//              os <<"pm" << endl;
//      }
//      os << s.getPurpose() << endl;
}
 
Keywords: Placing user generated char* statem…
 
Loading Advertisement...
 
[+][-]03/03/08 03:09 PM, ID: 21036688

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/03/08 03:11 PM, ID: 21036706

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/03/08 03:11 PM, ID: 21036708

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/03/08 03:22 PM, ID: 21036754

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/03/08 03:27 PM, ID: 21036797

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/03/08 03:28 PM, ID: 21036806

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/03/08 03:28 PM, ID: 21036811

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/03/08 03:31 PM, ID: 21036830

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/03/08 03:31 PM, ID: 21036834

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/03/08 03:33 PM, ID: 21036843

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/03/08 03:36 PM, ID: 21036870

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/03/08 03:41 PM, ID: 21036908

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/03/08 03:44 PM, ID: 21036936

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/03/08 03:47 PM, ID: 21036949

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/03/08 03:48 PM, ID: 21036959

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]03/03/08 03:48 PM, ID: 21036967

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/03/08 03:50 PM, ID: 21036977

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/03/08 04:10 PM, ID: 21037101

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/03/08 04:22 PM, ID: 21037169

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/03/08 04:35 PM, ID: 21037230

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/03/08 04:35 PM, ID: 21037231

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/03/08 04:35 PM, ID: 21037236

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/03/08 04:35 PM, ID: 21037237

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/03/08 04:38 PM, ID: 21037254

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/03/08 04:38 PM, ID: 21037259

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: C++ Programming Language
Tags: c++
Sign Up Now!
Solution Provided By: Infinity08
Participating Experts: 2
Solution Grade: A
 
 
[+][-]03/03/08 04:40 PM, ID: 21037266

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/03/08 04:42 PM, ID: 21037281

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/03/08 04:44 PM, ID: 21037291

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/03/08 04:49 PM, ID: 21037314

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/03/08 04:51 PM, ID: 21037327

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/03/08 04:56 PM, ID: 21037358

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/03/08 04:56 PM, ID: 21037361

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/03/08 05:01 PM, ID: 21037384

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/03/08 05:09 PM, ID: 21037433

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/03/08 05:13 PM, ID: 21037457

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/03/08 05:14 PM, ID: 21037458

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/03/08 05:29 PM, ID: 21037525

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20090824-EE-VQP-74 / EE_QW_2_20070628