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;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。