0
Example:
//Items, Amount
Apple,orange, Mango=10
Potato, bag of Carrot, Radish= 20
Coke, Fanta, Can of Pepsi=5
Cookie, bread = 5
(Always all fruits are assigned 
10,Vegies are 20 and so on)

Different items will be inputted by user like orange, Mango, bread etc..How to group similar items from input and store it somewhere and assign Amount like above.

For example if i store it in a 
std::Map with Items being key and 
Amount being value, It will store 
as below

Apple =10
Orange =10
Coke=5 and goes on and on.

I will get customer input as 'Coke' where i will access this map and get the Amount of it and do something with it.

Is there any better way to group same category first and assign the amount to it and access it.

Falcon
  • 37
  • 3
  • I feel like this is the same question I spoke to you about yesterday. For user input like this I really recommend making a GUI. Alternatively look at how command line programs work with many arguments. The user could enter -t "typename" -n "product name" then you parse the inputs into data structures – Natio2 Jul 17 '22 at 07:08
  • I need to get these only from console and user gives inputs this way only, thats a predefined requirement that cant be changed.. – Falcon Jul 17 '22 at 07:15
  • 1
    Yup hence the argument suggestion. Something like this: https://stackoverflow.com/questions/865668/parsing-command-line-arguments-in-c – Natio2 Jul 17 '22 at 07:48

0 Answers0