I am trying to draw shapes by receiving instructions from a file and then draw the shapes and output them into a separate file. The shapes I need to draw are box (filled), a diagonal line, and an isosceles triangle of the users user's choice and their choice of size. The shapes also can be either a *, ?, &, or#. I have gotten it to where I can import a file but I do not understand how to read it and execute the shapes.
I am not entirely sure. I missed the class period where they discussed this topic due to food poisoning and the notes the teacher posts online don't exactly explain things well. If my thought process is correct, I was thinking it would have to be a while loop, or an if/then statement. The instructions say this though,
For example, if the input file has the following:
B 5 *
D 4 ?
T 5 &
B 4 #
Then, the output file should have the following results:
You need to read a char first then an int and a char again.
Also you need an ifstream to read from files.
1 2 3 4 5 6 7 8 9
char shapeType, int size, char symbol;
ifstream src("your filename");
// handle possible error
while (src >> shapeType >> size >> symbol)
{
// depending on shapeType draw the shape
// create a function for each shape
}