Access Violation
Robert Jones
robertjones21 at HotPOP.com
Thu May 11 11:05:36 PDT 2006
Robert Jones said the following on 5/11/2006 1:35 PM:
Thanks Chris and David, below are the changes to the source which now
compiles and does what it is supposed to do.
>
> import std.c.stdio;
> import std.stdio;
>
> // number of kilometers in a astronomical unit
> const real au = 148800000.0;
const double au = 148800000.0;
> // number of kilometers in a light year based on light second being exactly 300,000km
> const real ly = 9467280000000.0;
const double ly = 9467280000000.0;
> real n;
double n = 0.0;
> real x;
double x = 0.0;
> real y;
double y = 0.0;
>
> int main()
> in
> {
> assert(au is 148800000.0); // ensure that au is exactly 1,448,800,000km
> assert(ly is 9467280000000.0); // ensure that ly is exactly 9,467,280,000,000km
> }
> body
> {
> writef("Enter number of light years: ");
> scanf("%f", x);
scanf("%lf", &x);
>
> // convert light years to kilometers
> y = x * ly;
>
> // convert kilometers to astonomical units
> n = y / au;
>
> writefln("\nThe number of astronomical units is %f", n );
> return 0;
> }
More information about the Digitalmars-d-learn
mailing list