Link to home
Start Free TrialLog in
Avatar of v_wall78
v_wall78

asked on

copying an array of pointers into an multidimensional array

I would like to know what I am doing wrong. I am keeping a history of commands and want to save argbuf each time I have used it into another array.
My code is like this:

char *argbuf[ARG_MAX+1];  
char **history[ARG_MAX+1];
   
if (his_count < HIS_MAX) {
    strcpy(*history[his_count], *argbuf);          // Add the command to history
    his_count++; }
else {                                           // Update history
    i = 0;
    while (i < (HIS_MAX-1)) {
        strcpy(*history[i], *history[i+1]);
        i++; }
     strcpy(*history[i], *argbuf); }

I get a segmentation fault, what am I doing wrong?
Thanks
ASKER CERTIFIED SOLUTION
Avatar of sunnycoder
sunnycoder
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial