Okay so i wanted to know how would i be able to bind an char type of array called ItemPrefixes to another type of array. to provide more clarification
i have to create this fruit portal with the use of both functions and arrays. I have declared both arrays as char itemPrefixes[] and int ItemPrices[]. the shopkeeper will be asked later on about the item prefixes eg 'A' = apple and the price for the apple being £2. However, i have to first bind the position 'i' in ItemPrefixes and itemPrices arrays to a particular item along with its price. eg itemPrefixes[0] = 'A' is binded with itemPrices[0] = 2.
you can try to use struct
:
struct item {
char name_item;
int price;
};
then you can create an array of struct
struct item my_array[10];
you can access the members in this way:
my_array[index].name_item;
my_array[index].price;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.