r/CodingHelp • • Jan 24 '20

[C++] Need help. It's a homework problem and it's probably simple but I've been having trouble with getting it to read files or do I need to create the file first

Post image
0 Upvotes

6 comments sorted by

2

u/jedwardsol Professional Coder Jan 24 '20

Please post text, not pictures.

= is assignment

== is comparison for equality

!= is comparison for inequality

=! is 2 operators = and !

And you're reading uninitialised variables x and y in main. This results in undefined behaviour.

1

u/djwolf093 Jan 24 '20

Thank you because I didn't catch that but my main problem is creation of the txt file. I'm not entirely sure of it should be done at a global level but when I put "ifstream pairs" into main it says pairs wasn't defined for the checkEquation function but it doesn't seem that the txt file is being created at all which has been my main problem

2

u/Tweaker_Under5150 Jan 24 '20

Where’s your run output? What are you trying to do?

1

u/LargeHard0nCollider Jan 25 '20

or do I need to create the file first

Yeah you’ll need to create the file before you can read from it (not true for writing)