| Thread overview | ||||||
|---|---|---|---|---|---|---|
|
August 10, 2004 error compiling? | ||||
|---|---|---|---|---|
| ||||
import std.string;
int main( char [][] args )
{
char[] str1;
real[char[]] array;
str1 = "akcom";
str1 ~= "rofl";
array[str1] = 1235.0123;
printf( "%f %f\n", 123.123, array[str1] );
return 0;
}
the output:
123.123000 -0.000000
| ||||
August 10, 2004 Re: error compiling? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to akcom | [You're posting to a deprecated 'group. Taking it to digitalmars.D....] akcom wrote: <snip> > real[char[]] array; <snip> > printf( "%f %f\n", 123.123, array[str1] ); <snip> %f denotes a double, not a real. IIRC you need %lf, not %f. Being on the Mac at the mo, I can't test it.... Or alternatively, use writef, which is much more typesafe. Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit. | |||
August 10, 2004 Re: error compiling? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon | Stewart Gordon wrote:
> [You're posting to a deprecated 'group. Taking it to digitalmars.D....]
>
> akcom wrote:
>
> <snip>
>
>> real[char[]] array;
>
> <snip>
>
>> printf( "%f %f\n", 123.123, array[str1] );
>
> <snip>
>
> %f denotes a double, not a real. IIRC you need %lf, not %f.
>
> Being on the Mac at the mo, I can't test it....
>
> Or alternatively, use writef, which is much more typesafe.
>
> Stewart.
>
thank you, works now :)
| |||
November 07, 2004 Re: error compiling? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to akcom | lf works for double, f works for float, neither works for real. In article <cfb75r$9mb$1@digitaldaemon.com>, akcom says... > >Stewart Gordon wrote: >> [You're posting to a deprecated 'group. Taking it to digitalmars.D....] >> >> akcom wrote: >> >> <snip> >> >>> real[char[]] array; >> >> <snip> >> >>> printf( "%f %f\n", 123.123, array[str1] ); >> >> <snip> >> >> %f denotes a double, not a real. IIRC you need %lf, not %f. >> >> Being on the Mac at the mo, I can't test it.... >> >> Or alternatively, use writef, which is much more typesafe. >> >> Stewart. >> >thank you, works now :) | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply