*i am trying to copy the value of
ar2[10] //in main. has the value 1,2,3,4,5
in
ar[10] //(in struct node). empty array
so to copy the value iam not sure if i could use a strcpy for ex,
strcpy(head->ar, ar2);
//here is my code
struct node
{
int ar[10]; //empty array
struct node *next;
};
struct node *head;
void insert_list1(int[]);
int main()
{
int ar2[10]; //let just say ar2 has the value 1,2,3,4,5
insert_list1(ar2);
}
void insert_list1(int ar2[])
{
struct node *cur_node = head;
struct node *new_node;
if(cur_node == NULL)
{
head = (struct node *) malloc(sizeof(struct node));
if(head == NULL)
{
printf("Node allocation failed.\n"); fflush(stdout);
exit(1);
}
strcpy(head->ar, ar2); //---NEED HELP WITH THIS LINE--------------
head->next = NULL;
}
else
{
while(cur_node != NULL)
{
cur_node = cur_node->next;
}
new_node = (struct node *)malloc(sizeof(struct node));
if(new_node == NULL)
{
printf("Node allocation failed.\n"); fflush(stdout);
exit(1);
}
strcpy(new_node->ar, ar2);
new_node->next = NULL;
cur_node->next = new_node;
}
}