So I've a method in which I'm trying to see which linked list is larger. If I find the larger one than I want to set a pointer to it, so when I do my arithmetic on the linked list I am subtracting the smaller from the larger, no matter if it is linked list A or linked list B. I've having some problems though. First of all when I see if there is data in my newly assigned pointer I get an error saying "invalid type argument of ‘->’ (have ‘struct node’)" Here is my code, any help would be much appreciated!
void subtraction(struct node** headOne, struct node** currOne, struct node** tailOne, struct node** headTwo, struct node** currTwo, struct node** tailTwo, struct node** headThree, struct node** tailThree, int lengthOne, int lengthTwo){
int numberOne, numberTwo, diff;
struct node* longest;
struct node* shortest;
printf("tailOne data = %d\n",(*tailOne)->data);
printf("tailTwo data = %d\n",(*tailTwo)->data);
if(lengthTwo > lengthOne){
longest = *currTwo;
shortest = *currOne;
}
else if (lengthOne > lengthTwo){
longest = *currOne;
shortest = *currTwo;
}
else{
if(((*tailOne)->data) > ((*tailTwo)->data)){
longest = *currOne;
shortest = *currTwo;
}
else{
longest = *currTwo;
shortest = *currOne;
}
}
while(longest){
printf("longest = %d",(*longest)->data);
}
}
int main(){
//initials
int i, number, lengthOne, lengthTwo;
char ch = 1;
//node pointers
struct node* headOne = NULL;
struct node* currOne = NULL;
struct node* tailOne = NULL;
struct node* headTwo = NULL;
struct node* currTwo = NULL;
struct node* tailTwo = NULL;
struct node* headThree = NULL;
struct node* currThree = NULL;
//create linked list
lengthOne = createLL(&headOne,&currOne, &tailOne, ch, number);
lengthTwo = createLL(&headTwo,&currTwo, &tailTwo, ch, number);
scanf("%c",&ch);
if (ch == '+'){
addition(&headOne, &currOne, &headTwo, &currTwo, &headThree, &currThree, lengthOne, lengthTwo);
}
else if(ch == '-'){
subtraction(&headOne, &currOne, &tailOne, &headTwo, &currTwo, &tailTwo, &currThree, &headThree, lengthOne, lengthTwo);
}