const char pointer function help

I'm having some issues with changing a char pointer and can't figure out where I'm going wrong


Here's my function for changing the description...
1
2
3
4
5
6
7
8
9
10
void appointment::changeDescription(const char * s)   //  change an existing description
{
    
    if (desc != NULL)
        strcpy(desc, s);
    
    if (s == NULL)
        return;
    
}


And here's the function that calls the change description function.
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
bool  keyBoardEnterAppointment( schedule & sched)  // return true if successful
// return false if full
{
    if (sched.isFull() == true)
    {
        cout << "Schedule is FULL." << endl;
        return false;
    }
    else
    {
        appointment s;
        int day, month, year;
        char *desc = new char;
        long source;
        
        cout << "*/Enter Appointment\\* ";
        cout << "Description: "; cin >> desc;
        cout << "Source: "; cin >> source;
        
        cout << "Month: "; cin >> month;
        cout << "Day: "; cin >> day;
        cout << "Year: "; cin >> year;
        
        s.changeDescription(desc);
        s.setSource(source);
        s.setDay(day);
        s.setMonth(month);
        s.setYear(year);
        sched.addtoSchedule(s);
        
        sched.print(cout);
        
        return true;
    }
}


It compiles and runs but the description remains the same as the default constructor description...
What do you set desc to in the default constructor?
Topic archived. No new replies allowed.