import std.stdio;
int main(string[] args) {
int a = 4;
short b;
double c;
int* ptr;
/* example of sizeof operator */
writefln("Line 1 - Size of variable a = %d/n", a.sizeof );
writefln("Line 2 - Size of variable b = %d/n", b.sizeof );
writefln("Line 3 - Size of variable c= %d/n", c.sizeof );
/* example of & and * operators */
ptr = &a; /* 'ptr' now contains the address of 'a'*/
writefln("value of a is %d/n", a);
writefln("*ptr is %d./n", *ptr);
/* example of ternary operator */
a = 10;
b = (a == 1) ? 20: 30;
writefln( "Value of b is %d/n", b );
b = (a == 10) ? 20: 30;
writefln( "Value of b is %d/n", b );
return 0;
}
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/265964.html