Help with arrays

Here is what I have:

1
2
3
4
5
6
7
  typedef struct list{
    struct list *next;
}listNode;

typedef listNode *listNodePtr;

listNodePtr *arr = (listNodePtr*)malloc(sizeof(listNodePtr)*9);

I send arr to an function like so: myFun(arr);
I catch it with an asterisk and inside myFun I create newArr
 
listNodePtr *newArr = (listNodePtr*)malloc(sizeof(listNodePtr)*15);

and than, inside this same function I do:
 
*arr = *newArr;


And it just doesn't want to work. When I try to print out the new array,
program hits a segmentation fault after 9th node.
What am I doing wrong?
Thank you.
Last edited on
Please show all of the relevant code.

if you try to assign one array to another: No, that's not possible.
Above you've implied that your list has 9 nodes, so why do you expect to access something after the 9th node?
Topic archived. No new replies allowed.