Okay, I finally got to a computer with a compiler and fixed the bugs you had. The main bug that was hiding all of the others was the fact that you used a keyword as a function name. The program was trying to use the C++ keyword delete to free a pointer instead of call your function. Here's the fixed code, I didn't test to see if it worked, that's up to you.
As a side note, there are several problems in your code that are considered bad style, not the least of which is casting malloc. That can hide errors, which is bad.
Code:
/* counts as line 1 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct variable
{
char *name;
void *value;
int type;
struct variable *next;
};
void linklist(struct variable *, char *);
void choices(void);
int empty(struct variable * );
char del(struct variable *, char *);
int main()
{
char select;
choices();
printf("<prompt>:");
scanf("%c", &select);
return 0;
}
void choices(void)
{
char select ,name[40], variable;
struct variable *newptr = NULL;
printf("\nVariable Allocation in an Operating System");
printf("\n\n");
printf("Make your choice from the following choices:");
printf("\nC to create a new variable");
printf("\nA to assign a value to a variable");
printf("\nD to delete a variable");
printf("\nS to show all variables");
printf("\nQ to quit the program\n");
printf("Your choice: ");
scanf("%c", &select);
while(( select != 'Q') && (select != 'q'))
{
switch( select )
{
case 'C' : case 'c' :
printf(" i Integer\n");
printf(" c Character\n");
printf(" f Float\n");
printf(" d Double\n");
printf("What type of variable do you choose: \n");
scanf("%c", &variable);
if(variable == 'i' || variable == 'c' || variable == 'f' || variable == 'd')
{
printf("Name of variable?: ");
fflush(stdin);
gets(name);
}
linklist(newptr, name );
break;
case 'A' : case 'a' :
printf("%s");
break;
case 'D' : case 'd' :
if(!newptr ){
printf("What variable do you want to delete?: \n");
scanf("%s", &variable);
if(! del (newptr, &variable) ){
printf("Varible %s was deleted\n", variable);
linklist(newptr, name);
}
else
printf("&s was not found\n", variable);
}
else
printf("List is empty\n");
break;
case 'S' : case 's' :
printf("%s");
break;
case 'Q' : case 'q' :
if (select == 'Q' || select == 'q')
{
exit (0);
}
default:
printf("Not a valid choice!\n");
choices();
break;
}
choices();
printf("<prompt>:\n");
scanf("%c", &select);
}
}
void linklist(struct variable *ptr, char *value)
{
struct variable *newptr, *prevptr, *current;
newptr = (struct variable *) malloc(sizeof(struct vaiable *));
if (!empty(newptr))
{
newptr ->name =(char *) malloc(sizeof(strlen(value)+1));
strcpy(newptr->name, value);
printf("Address\t Size(bytes)\t Value\t Name\n");
printf("%x\t%d\t%s\n", newptr ->name, sizeof(newptr->name), newptr->name);
printf(" ______________________________________\n");
newptr->next = NULL;
prevptr = NULL;
current = ptr;
while(current != NULL)
{
prevptr = current;
current = current ->next;
}
}
if (prevptr == NULL)
{
newptr ->next = ptr;
ptr = newptr;
}
else
{
prevptr->next = newptr;
newptr->next = current;
}
}
int empty (struct variable *ptr)
{
return (ptr==NULL ? 1: 0);
}
char del(struct variable *ptr, char *value)
{
struct variable *prevptr, *current, *tempptr;
if (value == (ptr)->value){
tempptr = ptr;
ptr = ptr -> next;
free(tempptr);
return *value;
}
else
{
prevptr = ptr;
current = ptr->next;
while(current != NULL && current -> value != value)
{
prevptr = current;
current = current -> next;
}
if (current != NULL)
{
tempptr = current;
prevptr -> next = current->next;
free(tempptr);
return *value;
}
}
return 0;
}
-Prelude