Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Very wierd compiling problem! (http://www.chiefdelphi.com/forums/showthread.php?t=43474)

Max Brin 07-02-2006 16:02

Very wierd compiling problem!
 
Hey,

I've tried to make a very simple statment:


Code:

float test = 3.14;

            printf("%f", test);

it wont print anything.. what seems to be the problem?

Thanks.

Eldarion 07-02-2006 16:21

Re: Very wierd compiling problem!
 
Quote:

Originally Posted by Max Brin
Hey,

I've tried to make a very simple statment:


Code:

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

Re: Very wierd compiling problem!
 
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.

Ryan M. 08-02-2006 07:06

Re: Very wierd compiling problem!
 
Quote:

Originally Posted by Alan Anderson
So far as I can tell, with the C18 compiler we use,

1) strings to be printf'd need a terminating \r

It 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

Re: Very wierd compiling problem!
 
Quote:

Originally Posted by Max Brin
Hey,

I've tried to make a very simple statment:


Code:

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

Re: Very wierd compiling problem!
 
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

Re: Very wierd compiling problem!
 
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.


All times are GMT -5. The time now is 01:39.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi