digitalmars.D.learn - pointers and structures
- %u (10/10) Apr 17 2011 what is the equivalent for this code in D?
- Christian Manning (12/22) Apr 17 2011 import std.stdio;
what is the equivalent for this code in D? #include <stdio.h> main() { struct S { int i; }; struct S s, *s_ptr; s_ptr = &s; s_ptr->i = 9; printf("%d\n", s_ptr->i); }
Apr 17 2011
On 17/04/2011 18:17, %u wrote:what is the equivalent for this code in D? #include<stdio.h> main() { struct S { int i; }; struct S s, *s_ptr; s_ptr =&s; s_ptr->i = 9; printf("%d\n", s_ptr->i); }import std.stdio; void main() { struct S { int i; } S s; S* s_ptr; s_ptr = &s; s_ptr.i = 9; writeln(s_ptr.i); // prints 9 writeln(s.i); // so does this }
Apr 17 2011