I made a linked list struct in C to contain two elements: a char* variable and a int variable. Wrote an INSERT function that created a Node with its char* data.
Now I'm trying to read an array and pass some of its information to a list already defined, but it just doesn't work out. If I try to insert any CHAR* to the list, it works, but it doesn't if the char* comes from the array.
void SaveToList(char* array[], int n){
char* temp;
if((strcmp(array[0], "declare")) == 0) {
temp = array[1];
list= Insert(list, temp);
printf("%s\n", temp);
}
}
I made sure the information on the array is coming right to the method, I need to save the info on the position 1 of the array, then insert it in the list. But the list just doesn't insert it right, it stores something else. I print out the data to see that is right, and in fact, it is, but not on the list.
ANY IDEA?
I appreciate your help.
THAN YOU VERY MUCH