Re: arrays in srucs

2020-07-31 Thread Andy Balba via Digitalmars-d-learn
On Friday, 31 July 2020 at 17:26:17 UTC, Paul Backus wrote: On Friday, 31 July 2020 at 17:02:46 UTC, Andy Balba wrote: The above code, compiles and runs ok .. but sometimes I get run runtime errors using the same paradym, which disappear when I substitute (img.p)[i] Any explanation for this

Re: arrays in srucs

2020-07-31 Thread Paul Backus via Digitalmars-d-learn
On Friday, 31 July 2020 at 17:02:46 UTC, Andy Balba wrote: The above code, compiles and runs ok .. but sometimes I get run runtime errors using the same paradym, which disappear when I substitute (img.p)[i] Any explanation for this ? Can you show an example where it doesn't work?

arrays in srucs

2020-07-31 Thread Andy Balba via Digitalmars-d-learn
I frequently use this paradigm for my image processing apps : import std.stdio ; struct S { int a, b; ubyte[] p; } void main() { S img= S(11,22) ; img.p = new ubyte[5]; foreach (i; 0 .. 5) { img.p[i]=cast(ubyte)(10+i) ; printf(" sa %d sb %d : %d\n", img.a, img.b, img.p[i] ); } } The above