Nishu wrote, On 01/03/07 07:50:
Hi All,
My Aim here is to increment lArray whether control goes inside if
statement or not. Is this a portable step and C guarantees that lArray
must be incremented?
#include<stdio.h>
int main(void)
{
int i = 7;
int array[] = {0,1,1,0,1,1,0};
Apart from the fact I would not write code like this, I would rearrange
the above two declarations to
int array[] = {0,1,1,0,1,1,0};
int i = (sizeof array) / sizeof *array;
Then you don't have to change the initialisation of i if you change the
size of the array.
int* lArray;
lArray = array;
while(i--)
{
if(*lArray++) /* Is this a portable step? */
Yes, it is completely portable, and almost equivalent to:
lArray++;
if (*(lArray-1))
I say almost because of sequence points which would be more important
with a more complex expression.
{
printf("enters in if loop\n");
}
}
return 0;
}
--
Flash Gordon