You are correct,
*IGBT
is a pointer to an array of size
width
. You access array elements by using pointer dereference (
*
) or an index (
[]
):
*IGBT = val;
IGBT[0] = val;
The
++
operator will increment the value of the variable. In your case it is a postfix operator (appended to the variable name) which will increment after other operations:
*IGBT++ = val;
*IGBT = val;
IGBT = IGBT + 1;
Omitting the increment in your case would only set the first element of the array which is probably not what you want.
But you can simplify your code by performing the increment outside the conditions:
for (i=0; i<width; i++){
if (*u0_Is[i] < *u1_Iref[i]){
*IGBT = 1;
if (*u2_Vce[i] >= 0.8 && (*u0_Is[i] < *u1_Iref[i]) ){
*THY = 1;
}
else {
*THY = 0;
}
}
else {
*IGBT = 0;
*THY = 0;
}
}
*IGBT++;
*THY++;
}
or just use the index
i
instead:
for (i=0; i<width; i++){
if (*u0_Is[i] < *u1_Iref[i]){
IGBT[i] = 1;
if (*u2_Vce[i] >= 0.8 && (*u0_Is[i] < *u1_Iref[i]) ){
THY[i] = 1;
}
else {
THY[i] = 0;
}
}
else {
IGBT[i] = 0;
THY[i] = 0;
}
}
}