View Full Version : Very wierd compiling problem!
Max Brin
07-02-2006, 16:02
Hey,
I've tried to make a very simple statment:
float test = 3.14;
printf("%f", test);
it wont print anything.. what seems to be the problem?
Thanks.
Eldarion
07-02-2006, 16:21
Hey,
I've tried to make a very simple statment:
float test = 3.14;
printf("%f", test);
it wont print anything.. what seems to be the problem?
Thanks.
I don't think the RC supports printf with a float modifier. Try %d with an integer value and see what happens.
Alan Anderson
07-02-2006, 16:21
So far as I can tell, with the C18 compiler we use,
1) strings to be printf'd need a terminating \r
and
2) %f is not supported.
So far as I can tell, with the C18 compiler we use,
1) strings to be printf'd need a terminating \rIt appears to be possible (at least for us) to have a printf without a terminating \r, as long as you get a \r in before the buffer is flushed. (presumably at the end of the loop)
pclements
08-02-2006, 12:41
Hey,
I've tried to make a very simple statment:
float test = 3.14;
printf("%f", test);
it wont print anything.. what seems to be the problem?
Thanks.
try using an intereger instead of a float, or even a char which will do the same thing a float does. a printable float is not compatable with the Ccompilers.
aaeamdar
08-02-2006, 13:03
2 things:
To be technical, your error (as you've explained it) is run-time, not compile-time error. A run-time error is something odd that happens during the execution of the code that you didn't expect. It may be a crash or just may not print what you thought it would.
The other "thing" is this: when do you need to print out floats? I dunno, maybe you do need them. Important values like motors are unsigned chars, however. Most of what you're working with is bits and chars. If you really need this to work, it's worth your time; otherwise, there are probably 400 better things to do.
Best of luck with it...
Paul dennis
steven114
08-02-2006, 15:43
If you absolutely must print out a float,do this: print the integer part, then take the remaining decimal part, multiply by some power of ten (say, 1000) and print out this number after a decimal point.
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.