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
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?
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