Changes (attempted!) made!
Thanks guys for your time!
Code:
#include <stdio.h>
#include "list.h"
#include <stdlib.h>
#define SIZE sizeof struct _LIST_
int* input, tmp, tail, node, list;
struct _LIST_
{
int number;
struct _LIST_ *next;
}
struct _LIST_ *LIST;
extern void print_stuff( int i )
{
printf("i is %d \n", i);
}
extern void create_list ()
{
list = malloc( SIZE );
scanf ("%d", &input);
if ( input != EOF)
{
list -> next = NULL;
list -> number = input;
}
else
{
printf ("no input");
}
while ( scanf("%d",&input) != EOF && input != -1 )
{
tmp = malloc( SIZE );
tmp->next = list;
tmp->number = input;
list = tmp;
}
}
extern void free_list (void* list)
{
while (list != NULL)
{
tmp = list;
list = list->next;
free( tmp );
}
}
extern void reverse_list (void* list)
{
list *reverse (list *node);
if (node->next == NULL)
{
tail = node;
return;
}
else
{
reverse (node->next);
node->next->next = node;
node->next = NULL;
}
}
extern void print_list( void* list )
{
int search( int key, LIST list )
while ((list != NULL) && (list->number != key))
{
printf ("%d", list);
list = list->next;
return (list != NULL);
}
}
extern void read_list( void* *plist )
{
int search( int key, LIST list )
while ((list != NULL) && (list->number != key))
{
list = list->next;
return (list != NULL);
}
}
extern void append_lists (void *list1, void *list2)
{
if (list1 == NULL)
list1 = list2;
else
{
tmp = list1;
while (tmp->next != NULL)
tmp = tmp->next;
tmp->next = list2;
}
}
Compiler errors are as follows
Code:
list.c:17: error: two or more data types in declaration specifiers
list.c: In function ‘create_list’:
list.c:31: error: expected expression before ‘struct’
list.c:33: warning: comparison between pointer and integer
list.c:36: warning: assignment makes integer from pointer without a cast
list.c:42: warning: comparison between pointer and integer
list.c:44: error: expected expression before ‘struct’
list.c:44: warning: assignment makes integer from pointer without a cast
list.c:45: error: invalid type argument of ‘->’
list.c:46: error: invalid type argument of ‘->’
list.c:47: warning: assignment makes pointer from integer without a cast
list.c: In function ‘free_list’:
list.c:58: warning: assignment makes integer from pointer without a cast
list.c:59: warning: dereferencing ‘void *’ pointer
list.c:59: error: request for member ‘next’ in something not a structure or union
list.c:60: warning: passing argument 1 of ‘free’ makes pointer from integer without a cast
list.c: In function ‘reverse_list’:
list.c:69: error: invalid operands to binary *
list.c:69: error: invalid operands to binary *
list.c:70: error: invalid type argument of ‘->’
list.c:77: error: invalid type argument of ‘->’
list.c:78: error: invalid type argument of ‘->’
list.c:79: error: invalid type argument of ‘->’
list.c: In function ‘print_list’:
list.c:89: error: expected declaration specifiers or ‘...’ before ‘LIST’
list.c:90: warning: ISO C forbids nested functions
list.c: In function ‘search’:
list.c:90: error: expected declaration specifiers before ‘while’
list.c:96: error: expected declaration specifiers before ‘}’ token
list.c:101: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
list.c:112: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
list.c:123: error: expected ‘{’ at end of input
list.c: In function ‘print_list’:
list.c:123: error: expected declaration or statement at end of input