Or you can create a member function of structure for value calculation;
Other then that you can create one more function to print the structure members, as you are trying to print the structure itself cout<<stock; which is incorrect.
You are getting the error messages because you have not defined what index is. In order to print the information for every struct in the Stock array, you need to loop through each member using the PrintStructure() function for each one.
You'll need to initialize an index variable (to keep track of which member of the array you are currently accessing).
You'll need to create a loop which increases that index variable with each iteration while also calling the
And stopping once the index variable is equal to the max array length.
As mentioned earlier, the for loop is probably the best option
You're getting there. In the struct stock, value is undefined until the function setValues() is ran.
So you will have to loop through the array running that function for each element (or you could run the function in one of the loops you already have so you don't have to make another loop just for that purpose).
Adding a total value will also be easy to implement and can be handled in either of the loops you currently have as well.
I am getting the correct output! I have no idea how clumsy/clutzy my code is but thanks to all of you, your instructions and suggestions, I finally got the code to work.
Enter the Company Name: abc
Enter the share price: 1
Enter the amount of shares: 1
Enter the Company Name: bcd
Enter the share price: 2
Enter the amount of shares: 2
Enter the Company Name: cde
Enter the share price: 3
Enter the amount of shares: 3
Enter the Company Name: def
Enter the share price: 4
Enter the amount of shares: 4
abc 1 1 1
bcd 2 2 4
cde 3 3 9
def 4 4 16
Total Portfolio Value: 30
Press any key to continue . . .