My first question is should I put name or name2 in the while loop (). How do I clear drawer like it asks? When I try to print the first character and then print the rest of the line did I correctly do so by printing firstLetter and name2??
My first question is should I put name or name2 in the while loop (). How do I clear drawer like it asks? When I try to print the first character and then print the rest of the line did I correctly do so by printing firstLetter and name2??
My first question is should I put name or name2 in the while loop ().
There are a couple of errors in the way you try to open the file.
17 18
ifstream name;
string name2 = openFile(name);
First I'd suggest a more meaningful variable name for the stream than just 'name'.
I tend to use something like fin and fout for input and output streams respectively, they are brief, and the similarity to cin and cout make their meaning fairly clear.
Then your code might look like this:
17 18
string filename = "data.txt";
ifstream fin(filename); // define and open the file
I don't know about your Graphics usage, it presumably belongs to some library which you are using.
A simplified version of your code, with no graphics, might look like this:
L this is a line
Once upon a time
C a circle
It was a dark and stormy night
R a rectangle
T a triangle
S something else
Output:
Line: this is a line
Error in input file : Once upon a time
Circle: a circle
Error in input file : It was a dark and stormy night
Rectangle: a rectangle
Triangle: a triangle
Error in input file : S something else
[Loaded data.txt]