im trying to write a program to see if two lists are equal
im really kinda lost at the moment, i havent gotten the compare function yet but i think that should be pretty easy, but im having some errors which u can see.
#include <stdio.h>
#include <stdlib.h>
typedef struct node{ int num; struct node *next; } NODE;
// having an issue before this equal, L1, and )
bool equal( node L1, node L2, int( *p_cmp_func )() ){
if( empty_list( L1 ) && empty_list( L2 )) return TRUE;
if( empty_list( L1 ) && !empty_list( L2 )) return FALSE;
if( !empty_list( L1 ) && empty_list( L2 )) return FALSE;
return((*p_cmp_f)(DATA(L1),DATA(L2)) && equal(NEXT(L1), NEXT(L2), p_cmp_f));
}
int main( int argc, char *argv[] ){
NODE *L1, *L2;
NODE *temp ;
int n, i, num;
printf( "\n How many numbers do you want to enter for the first list? " );
scanf( "%d", &n );
L1 = NULL ;
for( i = 1; i <= n ; i++ ) {
temp = ( NODE * ) malloc( sizeof( NODE ) );
printf( "Please enter a number: " );
scanf( "%d", &num );
temp -> num = num;
temp -> next = L1;
L1 = temp ;
}
printf( "\n How many numbers do you want to enter for the second list? " );
scanf( "%d", &n );
L2 = NULL ;
for( i = 1; i <= n ; i++ ) {
temp = ( NODE * ) malloc( sizeof( NODE ) );
printf( "Please enter a number: " );
scanf( "%d", &num );
temp -> num = num;
temp -> next = L2;
L2 = temp;
}
printf( "\n\n" );
/* im also having some issues here but i think these are related to not having compare list written, and the previous error*/
if( equal( L1, L2, comparelist() ) == TRUE )
printf( "The lists are equal." );
if( equal( L1, L2, comparelist() ) == FALSE )
printf( "The lists are not equal." );
return( 0 );
}