Thread: creating a store

  1. #1
    Registered User
    Join Date
    Dec 2017
    Posts
    37

    creating a store

    I have to make a store to use money to buy vveapons
    I need help hovv to create a store
    Also hovv do i get rid of 0 array


    Code:
    #include "stdafx.h"
    using namespace std;
    #include <iostream>
    
    int main()
    {
        
        char *weapons[6] = {"banana bomb","grenade","bazooka","uzi","shotgun","air strike" };
        
        cout << weapons[3] << endl;
        
        
        return 0;
    }

  2. #2
    Banned
    Join Date
    Aug 2017
    Posts
    861
    to get rid of the zero array? you mean the element? just do not use it. start with 1 instead.

    {keyboard broke, no w got a vv instead?)

    first think of what information you need for a store to keep track of the information. item types , serial number, whole sale cost, retail cost. tax percentage, amount in stock, then
    for the customer what information do you need to keep track of?

    create structs to reflect the same then go from there.
    Last edited by userxbw; 12-16-2017 at 12:28 PM.

  3. #3
    Registered User
    Join Date
    Jun 2017
    Posts
    157
    The best way to get rid of the array is to use a vector, also you better use strings.

    Code:
    #include <vector>
    #include <string>
    
    vector<string> weapons = 
    { 
       "banana bomb","grenade","bazooka","uzi","shotgun","air strike" 
    };
    I also would recommend to create a struct or class for the weapons like so:

    Code:
    struct Weapon
    {
      string name;
      double price;
      // and maybe power, weight and some other infos
    }
    Then you can create a store as a vector<Weapon> or maybe create a class store;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 21
    Last Post: 12-13-2016, 03:46 AM
  2. Help creating global const char[] to store users home dir
    By KoRn KloWn in forum C Programming
    Replies: 4
    Last Post: 10-06-2012, 02:47 PM
  3. store data from ifstream and store in link list
    By peter_hii in forum C++ Programming
    Replies: 2
    Last Post: 10-26-2006, 08:50 AM
  4. how should i store these?
    By Waldo2k2 in forum C++ Programming
    Replies: 8
    Last Post: 07-10-2002, 02:10 PM
  5. Do you store store one off data arrays in a class?
    By blood.angel in forum C++ Programming
    Replies: 5
    Last Post: 06-24-2002, 12:05 PM

Tags for this Thread