0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
There aren't any scanf calls in the ReadFile function. And when I changed them previously from scanf to fscanf this worked fine, so if your fscanfs are broken then that's a compiler bug I can't help you with.
0
sadam's Avatar, Join Date: Apr 2011
Go4Expert Member
Quote:
Originally Posted by xpi0t0s View Post
There aren't any scanf calls in the ReadFile function. And when I changed them previously from scanf to fscanf this worked fine, so if your fscanfs are broken then that's a compiler bug I can't help you with.
you mean that the program in your computer works correctly?
can you tell me what result does it post out?

dist = ???
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
I haven't got that far with it. And I'm pretty sure there are other errors as well. What distance do you expect it to print out from calculating the value manually from the test data?
0
sadam's Avatar, Join Date: Apr 2011
Go4Expert Member
Quote:
Originally Posted by xpi0t0s View Post
I haven't got that far with it. And I'm pretty sure there are other errors as well. What distance do you expect it to print out from calculating the value manually from the test data?
i don't know, i haven't calculated the distance yet, what other errors are there?
i think it's correct except the readfile
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
You need to find the errors yourself. I'm not going to do it for you, but I will help you learn how to find them. Basically it's very easy: just add printf statements to the code, displaying where it's up to and what values it's calculated, then you can see where it goes wrong (if at all). You WILL DEFINITELY need to have calculated the value manually, because if you can't do that then you have no chance of being able to program a computer to do it.

It's easier with a debugger of course, particularly the visual debugger provided with Visual Studio 2010 but I realise not everyone has access to such products. Hence the printf suggestion, which I still use even with VS, when building a program it really helps me to focus on what the code should do if I've already added a bunch of printf's that display what the program should do.
0
sadam's Avatar, Join Date: Apr 2011
Go4Expert Member
ok i have done what you told me by adding several printf's in the program and i found out that the main() starts working fine and when i call the readfile it stops working
also in the readfile it posts me only the printf that i have add before the scanf

so what should i understand with this? maybe there are no errors except the readfile??
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
Post the code.

no errors: nope, there is definitely still at least one error that will definitely cause you to get wrong results. It'll be up to you to find it.
0
sadam's Avatar, Join Date: Apr 2011
Go4Expert Member
Quote:
Originally Posted by xpi0t0s View Post
Post the code.

no errors: nope, there is definitely still at least one error that will definitely cause you to get wrong results. It'll be up to you to find it.
where man?? help me to find it
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
Stop replying immediately and THINK.
0
sadam's Avatar, Join Date: Apr 2011
Go4Expert Member
help me man, the deadline is tomorrow