#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0

    Sub scripted value is neither an array nor pointer nor vector


    I am trying to write a code that reads in an item name, quantity and price using a typedef struct, but keep getting this error.

    Sub scripted value is neither an array nor pointer nor vector on line 76, 79, 82, 100,101 and 102.

    I had the code working before but, when i went to display the inventory nothing would appear.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0
    #include <stdio.h>
    #define item 100
    #define quantity 100
    #define price 100

    typedef struct Management
    {
    char arrayi;
    int arrayq;
    float arrayp;



    }RECORD;

    void addToInventory(RECORD one,int *totalItems);
    void displayInventory(RECORD one,int totalItems);
    void inventorySave(RECORD one, int totalItems);

    int main()
    {
    int x;
    int y=1;
    int totalItems=0;
    RECORD one[100];

    while(y==1)
    {//begining of while

    printf("1. Add to Inventory\n");
    printf("2. Adjust Quantity of an Item\n");
    printf("3. Print Inventory\n");
    printf("4. Remove an Item from Inventory\n");
    printf("5. Quit and Save inventory\n");
    scanf("%d",&x);




    switch(x)//begining of switch
    {


    case(1):
    addToInventory(*one,&totalItems);//function call
    break;

    case(2):
    printf("The user chose to adjust the quantity of an item.\n");
    break;

    case(3):
    displayInventory(one,totalItems);//function call
    break;

    case(4):
    printf("The user has chosen to remove an item from inventory.\n");
    break;

    case(5):
    inventorySave(one,totalItems);//save function
    printf("All items have been saved and the program has been quit.\n");
    y++;//ends switch

    break;

    }
    }
    }//end of main

    void addToInventory(RECORD one,int *totalItems)
    {


    printf("Enter the item being added to the inventory.\n");
    scanf("%s",one[*totalItems].arrayi);//item

    printf("Enter the quantity of the item.\n");
    scanf("%d",&(one[*totalItems].arrayq));//quantity

    printf("Enter the price of the item.\n");
    scanf("%f",&(one[*totalItems].arrayp));//price

    (*totalItems)++;//+1 to total items




    }


    void displayInventory(RECORD one,int totalItems)
    {


    int x=0;
    printf(" Item Quantity Price\n\n");
    for(x=0;x<totalItems;x++)
    {
    printf("%10s",one[x].arrayi);
    printf("%17d",one[x].arrayq);
    printf("%13.2f\n",one[x].arrayp);

    }





    }


    void inventorySave(RECORD one,int totalItems)
    {




    }

IMN logo majestic logo threadwatch logo seochat tools logo