I have written a program that asks a user to input a string of digits, accepting a decimal as well, and separates the digits into different stacks. My professor has asked that I edit the program to accept any number of digits so it needs to be modified to dynamically stack the string that is entered. I am unsure how to do this currently and any assistance will be greatly appreciated.
PS: This is my first post so any general formalities regarding the code and future posts will also be appreciated. It does not appear that my spacing in the code is being saved when I copy/paste it over and look at the preview so apologies for that.
If you edit your post, highlight the code part, then click the <> button in the format palette on the right side of the post, that will format the code for the forum. That'll make it easier to read :)
Edit: When I had this assignment to do, we had to build our own array class that would dynamically grow if necessary - not sure if your professor is expecting you to do that instead of use vector.
Unfortunately I can not use a vector due to the specifics on the assignment. I'm sitting at an 80 right now due to the program working as needed, however the 20 points I'm missing is because of the 5 digit maxstack and he requested it to be modified to allow for any # of digits specified by the user. I have searched all over for a way to do this and toyed around with modifying the program many times but can't seem to make it work dynamically.
I guess you could determine the length of the number the user enters, then use that number to dynamically allocate the array in the class. You could implement a constructor that would take the number as an integer and use new to allocate an array of that size. You'd also create a destructor for the class to delete the dynamically allocated memory.