C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 3rd, 2012, 08:40 AM
CoryH94 CoryH94 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 2 CoryH94 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 m 40 sec
Reputation 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.

Reply With Quote
  #2  
Old December 3rd, 2012, 08:41 AM
CoryH94 CoryH94 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 2 CoryH94 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 m 40 sec
Reputation 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)
{




}

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Sub scripted value is neither an array nor pointer nor vector

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap