I'm working on a slightly different take on linked lists than I've tried to tackle before, and it's leading to some issues. I'm familiar with handling a linked list using simple integer parameters, but I'm trying to handle a character array, and can't figure out exactly how to add to a list in this situation:
struct process{
pid_t pid;
char userArgument[1024];
struct process* next;
};
class processList{
private:
process *head, *tail;
public:
processList(){
head = NULL;
tail = NULL;
}
void add(int pid, char argument[]){
process *tmp = new process;
tmp->pid = pid;
tmp->userArgument = argument; //PROBLEM. I want this to take a character array passed to add() and use it as the userArgument for this new process
tmp->next = NULL;
if(head == NULL){
head = tmp;
tail = tmp;
}
else{
tail->next = tmp;
tail = tail->next;
}
}
};
The intended behaviour of the add function would be to create a new process with a pid of type int, and a new userArgument of type char[]. In the line I've marked as the problem, however, it throws up an error, and I've tried alternative versions without success (passing add() a string instead, using c_str(), etc). I'm stuck trying to get this to work, and would appreciate any help that can be offered.