As a project for school I am doing a simple fraction calculater. However, I have decided to go a little further with it and have it reduce the fractions for me
currently i have the expression output on one line then the reduced answer on the secdond, for example:
4/8 * 1/2 = 4/16
= 1/4
is there a way to format my output so the "=" lines up everytime as if you were to write out the expression on paper?
ps. the output for the first expression is as follows:
You could use setwidth() to make the size of the left hand expression be at least a certain length. This wouldn't make it work in all cases, however. The first way that I think of would be to read the entire equation into a stringstream first and get the length of the equation so you know how far to space over.
sorry i am unfimiliar with both a stringsream and setwidth could you show me the basic syntax?
EDIT:
also, i need to find the length of the expression that is output onto the screen which isnt one string but a string followed by a variable followed by a string etc. im not sure if stringstream will work with that.