I'm supposed to modify an existing payroll program from using normal c++ strings to using c-strings...
and I don't get them.
Can someone explain them to me or direct me to a tutorial on them?
I understand the concept that they're basically char arrays but I don't understand how to populate them or use them in a program when I'm trying to read/write from a file.
If you understand that they are character arrays, and you understand how to allocate/deallocate them, then you should be able to use the functions provided in <cstring> with ease. Remember they were writeen in C originally, so they aren't very C++ish
And to make things easier for any other questions, this is the class that I'm working with.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
class Employee
{
private:
int id; // employee ID
char name[21]; // employee name in c-string
double hourlyPay; // pay per hour
int numDeps; // number of dependents
int type; // employee type
public:
Employee( int initId=0, char initName[], double initHourlyPay=0.0, int initNumDeps=0, int initType=0 ); // Constructor
bool set(int newId, char newName[], double newHourlyPay, int newNumDeps, int newType);
int getID() {return id;}
char getName() {return name[21];}
double getHourlyPay() {return hourlyPay;}
int getNumDeps() {return numDeps;}
int getType() {return type;}
};
I know that there's something wrong with the set function and constructor as well