#include <stdio.h>
#include <stdlib.h>
#include "globals.h"
#include "list.h"
status write_int(generic_ptr p_n)){
printf(" %d " , *(int *)p_n ) ;
return OK ;
}
int compare_int( generic_ptr x , generic_ptr y){
if( *(int*) x < *(int *)y ) return -1 ;
if( *(int*) x > *(int *)y ) return 1 ;
return 0 ;
}
int main( int argc , char *argv[] ){
list L1 , L2 ;
int n,num,i, *p_int ;
init_list(&L1) ;
init_list(&L2) ;
printf("\nHow many umbers are there in list 1 ? ") ;
scanf("%d" , &n) ;
for(i = 1 ; i <= n ; i++){
printf("\nEnter a number: " ) ;
scanf("%d" , &num) ;
p_int = (int *)malloc(sizeof(int) ) ;
*p_int = num ;
append(&L1,(generic_ptr)p_int) ;
}
printf("\nList 1: ") ; traverse(L1,write_int) ;
printf("\n\nHow many numbers are there in List 2 ? " ) ;
scanf("%d" , &n) ;
for(i = 1 ; i <= n ; i++){
printf("\nEnter a number: " ) ;
scanf("%d" , &num) ;
p_int = (int *)malloc(sizeof(int) ) ;
*p_int = num ;
append(&L2,(generic_ptr)p_int) ;
}
printf("\nList 2: ") ; traverse(L2,write_int) ;
if(equal(L1,L2,compare_int)) printf("\n\nThe twp lists are equal.\n\n") ;
else printf("\n\nThe two lists are not equal.\n\n") ;
return 0 ;
}
Errors
||In function 'write_int':|
|6|error: expected declaration specifiers before ')' token|
|13|error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token|
|21|error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token|
|65|error: expected '{' at end of input|
||=== Build finished: 4 errors, 0 warnings ===|