![]() |
|
#1
|
|||
|
|||
no output, usage of sqrt and powhey everyone
this program is on C and i do not need to enter a math library because with putty you enter the match library by a special means of compiling (gcc -lm -o program_name program_name.c) here is the distance formula for determinng the distance between two coordinates distance=square root of [(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)]. i'm currently getting no out put, just a blank line. i think the problem may lie in my inexperience with math library usage or just math in general any help greatly appreciated and by the way i'm another person who needs this code before midnight CPP / C++ / C Code:
|
|||
|
#2
|
|||
|
|||
Re: no output, usage of sqrt and powQuote:
This makes no sense to me. Do you mean that gcc gives no errors even though you don't include <math.h>? Well OK, but that has nothing to do with the -lm switch on the command line. I respectfully suggest that you use the following command line: Code:
(You really, really, really, really should include <math.h>, and turn on those compiler warnings!) Quote:
Make the program tell you what it is seeing. Something like this: CPP / C++ / C Code:
Regards, Dave (Now try it with <math.h> and without <math.h>) |
|
#3
|
|||
|
|||
Re: no output, usage of sqrt and powthanks for the try but the problem actually was in my pow constructs, i replaced them by just timesing each equasion by itself.
btw my compiler does not recognize #include <math.h> thanks for your help but i got it now |
|
#4
|
|||
|
|||
Re: no output, usage of sqrt and powQuote:
Well, putting printf() statements before and after every calculation is a valid way of debugging, regardless of the nature of the errors. Now, I will indulge in a little editorial: I have no idea what "putty" is, but gcc expects <math.h>. If you are using some trumped up toy interface that hides facts of life from you, you will be in for a rude awakening when (if) you ever get turned loose in (on) the so-called "real world". There was nothing wrong with the syntax of your original program. If your compiler makes you break arithmetic expressions down into simpler forms than the language allows, your educational instution is doing you a huge disservice. That's just my opinion, of course, and worth every bit that you paid for it. But consider this: If your compiler doesn't recognize <math.h>, what other standard language constructs are being kept from you? How could you know what you are mis-learning? Good luck. Regards, Dave |
Recent GIDBlog
Vista ?Widgets? on Windows XP by LocalTech
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The