title: Adding elements to array struct in c++
body: <p>im doing an assignment on c++ and im stuck on how i would add a new transaction to my work, with a user defined numShares, and pricePerShare.</p>
  
  <p>i have a transaction struct which looks like this:</p>
  
  <pre><code>struct Transaction
  {
  string stockSymbol;     // String containing the stock symbol, e.g. "AAPL"
  string buyerName;       // String containing the buyer's name e.g. "Mr Brown"
  int buyerAccount;       // Integer containing an eight digit account code
  int numShares;          // Integer containing the number of sold shares
  int pricePerShare;      // Integer containing the buy price per share
  };
  </code></pre>
  
  <p>this is the buildTransaction class:</p>
  
  <pre><code>static Transaction* buildTransactions(int numTransactions)
  {
      int maxShareVolume = 100000;
      int maxSharePrice = 1000;
  
      Transaction *transactions = new Transaction[numTransactions];
  
          for(int idx = 0; idx &lt; numTransactions; idx++)
          {
              transactions[idx].stockSymbol = pickRandomStockSymbol();
  
              std::string buyerName = pickRandomBuyer();
              transactions[idx].buyerName = buyerName;
              transactions[idx].buyerAccount = lookupBuyerAccount(buyerName);
  
              transactions[idx].numShares = 1 + rand() % maxShareVolume;
              transactions[idx].pricePerShare = 1 + rand() % maxSharePrice;       
          }
  
          return transactions;
      }
  </code></pre>
  
  <p>how would i use that to add data to the transactions array using this:</p>
  
  <pre><code>void Analyser::addTransactions(Transaction* transactions, int numTransactions)
  </code></pre>
  
  <p>i would assume from this that all i would really need to have as user input would be the amount of shares, and the price per share, but that the other information fills itself in automatically, from choosing from the arrays.</p>