Variable Allocation in a simple operating system

This is a discussion on Variable Allocation in a simple operating system within the C Programming forums, part of the General Programming Boards category; I am getting the following errors for my program: line 138: unterminated string or character constant line 35: possible real ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    18

    Arrow Variable Allocation in a simple operating system

    I am getting the following errors for my program:
    line 138: unterminated string or character constant
    line 35: possible real start of unterminated constant
    For the program I am supposed to allow the user to create new variables, delete existing varaibles, assign values to existing variables by name, and display a list of all the variables. Can anyone help me correct the errors I am getting, thank you.
    here is my code:

    #include <stdio.h>
    #include <stdlib.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 delete(struct variable *, char *);

    int main()
    {
    char select;

    choices();
    printf("<prompt>:");
    scanf("%c", &select);
    }

    void choices(void)
    {
    char select ,names[40] ,i,c,f,d,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(! isempty (newptr) ){
    printf("What variable do you want to delete?: \n");
    scanf("%s", &variable);

    if(! delete (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 (newptr != NULL)
    {
    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;
    }
    }

    nt empty (struct variable *ptr)
    {
    return (ptr==NULL ? 1: 0);
    }
    char delete(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';
    }

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Guess what? Your compiler was right. See line 35:

    > printf("Make your choice from the following choices: );

    Ta dah! You forgot your end quote. The compiler told you where to look.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sorting number
    By Leslie in forum C Programming
    Replies: 8
    Last Post: 05-20-2009, 05:23 AM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 04:00 PM
  3. My favourite operating system
    By techie in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 07-19-2002, 07:29 AM
  4. Microsoft = The Best Operating System
    By Troll_King in forum A Brief History of Cprogramming.com
    Replies: 92
    Last Post: 02-08-2002, 01:32 PM
  5. Need help
    By awkeller in forum C Programming
    Replies: 2
    Last Post: 12-09-2001, 03:02 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21