Question #31786

Add a member function
Void Employee::format(char buffer[], int buffer_maxlength
to the Employee class. The member function should fill the buffer with the name and salary of the employee. Be sure not to overrun the buffer. It can hold buffer_maxlength characters, not including the’\0’ terminator. (That is, the buffer has buffer_maxlength + 1 bytes available.) Be sure to provide a ‘\0’.

Expert's answer

void& Employee::format(char buffer[], int buffer_maxlength)
{
char *wch = new char;

wch[buffer_maxlength];

cin>>wch;

for(int i=0; i<buffer_maxlength-1; ++i)
{
buffer[i]=wch[i];
}

delete wch;
}
LATEST TUTORIALS
APPROVED BY CLIENTS