My problem is that i do not know how to update the memory locations
It sounds like your instructor wants you to useglobal variables for rootone and roottwo. Check with him to see if that's true.
to write into an output file without overwriting what is already there from the previous calculations.
Open the output file for append. Use"a" instead of "w"
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
Thanks for the reply.
I managed to get the file printing to work, however i still cannot update the memory locations pointed to root1 and root2 with the two values of the quadratic root. Is there a specific way of writing an equation to update the memory locations?
What memory locations doesrootone and roottwo point to? They look like simple variables to me. And simply assigning a value with the = sign updates the variable, and that you are doing. Therefore, I guess I have no idea what your question really is.
So, I suppose the question I have is "what part of the first half of my response did you not understand?"
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
spec80, ignore walt. He's apparently got some hostility issues with people who have honest questions. nice quality for a moderator.
anyhow, don't panic. you're 99% done.
instead of locally calling "rootone" and "roottwo" inside your subroutine, use the global variables that you already declared outside of main() ... "root1" and "root2"
and since you're going to use them as global variables (which is the case, because you declared them outside of main), there's no need to declare them as pointers. just make them straight-up type doubles.
then in the subroutine, instead of assigning the results of your calculations to "rootone" and "roottwo", assign them directly to the globals "root1" and "root2".
when you return back to the main( ) routine, the roots will still be in those global variables, ready for you to do whatever you want with them ... how nice, isn't it! aren't globals wonderful? enjoy them now, while you can.... they'll be violently beaten from you soon enough!
one other thing. theres no reason to make your "compute_roots" subroutine declared as a type "double". you're only returning a 1 or a 0... declare it as an "int", or "unsigned"
jephthah
Posting Maven
2,587 posts since Feb 2008
Reputation Points: 2,143
Solved Threads: 179
thats fine walt. you can win the point game, and you can continue with your smug self-righteousness while berating new people for asking question.
jephthah
Posting Maven
2,587 posts since Feb 2008
Reputation Points: 2,143
Solved Threads: 179
>nice quality for a moderator.
Moderators have one job: enforce the rules. Walt's behavior is no more or less restricted than your behavior, and the comment that offends you so much is acceptable according to Daniweb's rules.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
ok, sure. you're the boss.
:)
jephthah
Posting Maven
2,587 posts since Feb 2008
Reputation Points: 2,143
Solved Threads: 179